Question
In MATLAB, use the two given snippets of code to make an animated graph. ====Write the snippet of code to plot a sine wave from
In MATLAB, use the two given snippets of code to make an animated graph.
====Write the snippet of code to plot a sine wave from 0 to pi, but with every second passed, the span of the sine wave will be extended by 1 pi and it will stop extending after 10 seconds. Use pseudocode to describe your algorithm.
====Then rewrite example code using a while loop in place of a for loop. Make sure that your loop supports any increment of x, such as pi/10, pi/100, or even pi/10000. Note: If suddenly Matlab stops responding, you need to use (control and c) to cancel the current operation. This could happen if your while loop is never met with a false. Use pseudocode to describe your algorithm.
Code snippets:
Plotting the graph
x = 0:pi/100:2*pi;
y = sin(x);
plot(x,y)
Time increments
for i = 1:1:10
pause(1);
disp(i);
end
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started