how to plot a graph gradually?

20 visualizaciones (últimos 30 días)
Saad Rana
Saad Rana el 13 de Jun. de 2021
Comentada: Saad Rana el 13 de Jun. de 2021
Hello everyone,
I am trying to gradually plot a graph as if its plotting in real time. I have tried a code but it doesn't seem to work saying Subscript indices must either be real positive integers or logicals.
Here's my code:
clc
a = 0:0.1:10;
x = sin(2*pi*3*a);
for i = 0:1:100
plot(a(i),x(i))
pause(1)
end
can anyone help me with this?

Respuesta aceptada

Walter Roberson
Walter Roberson el 13 de Jun. de 2021
a = 0:0.1:10;
x = sin(2*pi*3*a);
for i = 1:length(a)
plot(a(1:i),x(1:i))
pause(1)
end
However I recommend that you read about animatedline()

Más respuestas (0)

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by