Using plot command in a loop
Mostrar comentarios más antiguos
Hey All,
I tried to change the input argument for plot command but it didn't work as I discovered that plot doesn't accept it as an input argument:
for i= 1:20
figure, plot((sprintf('Data%d',i))) , hold on; plot(f_mean*ones(length(sprintf('Data%d',i)),1),'r'); plot(sprintf('alpha_data%d',i),'g'); plot(sprintf('alpha_data_neg%d',i),'g'); hold off; axis ([0 350 0.28 0.32])
end
What can I change in my code to make it work??
1 comentario
Azzi Abdelmalek
el 19 de Oct. de 2012
you are trrying to plot a string. What data do you want to plot?
Respuesta aceptada
Más respuestas (2)
MANJUNATH
el 19 de Oct. de 2012
0 votos
try using string to num conversion
1 comentario
Yasmin Tamimi
el 19 de Oct. de 2012
Robert Cumming
el 20 de Oct. de 2012
using eval is almost always a bad idea. Store your data as
Data(1), Data(2) etc..... rather than Data1, Data2 etc....
If you end up needing to use eval to solve your problem your looking in the wrong area for a solution.
Why should you not use it:
1. Its hard to debug 2. Its very slow.
Categorías
Más información sobre Creating, Deleting, and Querying Graphics Objects en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!