Plot multiple data in one plot using for loop

3 visualizaciones (últimos 30 días)
Hamidreza Esmalifalk
Hamidreza Esmalifalk el 17 de Feb. de 2019
Editada: madhan ravi el 17 de Feb. de 2019
I want to plot these 8 time series using for loop but it plots just the last one alone.
for i=1:8
plot(x,y{i},'LineWidth',2);
hold on
end
hold off

Respuesta aceptada

madhan ravi
madhan ravi el 17 de Feb. de 2019
Editada: madhan ravi el 17 de Feb. de 2019
If you look the data in each cell closely infact they are all the same so all the plots overlap each other:
plot(x,[y{:}]) % you don't need a loop
  1 comentario
madhan ravi
madhan ravi el 17 de Feb. de 2019
To check if each cell are same:
isequal(y{:}) % if returns one then they are all the same [resulting with just one plot]

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by