Using the program MATLAB, Create a script that uses the \'plot\' and \'hold on\'
ID: 3802068 • Letter: U
Question
Using the program MATLAB, Create a script that uses the 'plot' and 'hold on' function to draw a line from the upper left corner to the lower right corner of a 100x100 grid. You will need to pause your loop in order to cleanly view the animation.
*Note: The argument in the pause function is measured in seconds so a 0.1 second pause in your loop will be implemented as follows:
pause(.1)
*Keep in mind that pause does not fully stop your loop – it merely pauses for a specified amount of time then continues to run.
Please show all steps! Thank you!
Explanation / Answer
x=zeros(1,100);
y=zeros(1,100);
hold on;
for i=1:100
x(i)=i-1;
y(101-i)=x(i);
plot(x(i),y(101-i));
pause(0.1);
end
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.