multiple plots from array without loop
Mostrar comentarios más antiguos
Hi all
I have an array (X) holding lets say 20 cycles of data. I would like to plot the entire 20 cycles as a dashed line plot, and then markup (with a solid line) specific segments of the graph, the start and end indexes are in two different vectors S1 and S2. Would it be possible to do something like this:
plot(X,'k--');
hold on;
plot(X([S1:S2]),'r');
instead of using a loop as:
plot(X,'k--');
for i=1:length(S1)
plot(X(S1(i):S2(i),r,)
end
The only reason is I would like to avoid loops in my code, as I am plotting several graph segments within my code, and then having 30 for loops does not look good :)
Best, Tommy
2 comentarios
KSSV
el 2 de Dic. de 2016
This will work:
plot(X,'k--');
hold on;
plot(X([S1:S2]),'r');
You can try on your own...why doubt?
Respuesta aceptada
Más respuestas (1)
Tommy B
el 2 de Dic. de 2016
0 votos
Categorías
Más información sobre Mathematics en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!