How create moving plot in MATLAB grader (in moodle)

I want students to create a moving plot like:
t = linspace(1,10,10);
for i=1:10;
pause(0.2);
x = i./t;
plot(x)
end
But in grader they can only see the last plot.

 Réponse acceptée

Cris LaPierre
Cris LaPierre le 6 Avr 2022

0 votes

You cannot create an animation in MATLAB Grader. At least not one that you will be able to see. This is because your code actually executes in the cloud, and only the final results are displayed in your browser. The plot you see is a jpeg of the final figure created by your code.

Plus de réponses (1)

Anirban Mandal
Anirban Mandal le 6 Avr 2022
Modifié(e) : Anirban Mandal le 6 Avr 2022
You can use the following code for generating all the 10 plots. Let me know if this the solution you are looking for.
t = linspace(1,10,10);
for i=1:10;
pause(0.2);
x = i./t;
figure(i)
plot(x)
end

2 commentaires

No, I want it in one figure, and I want it will be moving.
thank you.
Then you can use the comet function for a moving plot.
t = linspace(1,10,10);
for i=1:10;
pause(0.2);
x = i./t;
comet(x)
end

Connectez-vous pour commenter.

Catégories

En savoir plus sur Discrete Data Plots dans Centre d'aide et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by