Iterative approach for plot function

1 次查看(过去 30 天)
Mo
Mo 2014-3-26
Hi,
I am trying to find a way to summarise the following lines of code to some sort of for loop with switch statements. Notice the trend and repetition inside the plot functions.
plot([X 0],[-Ystep -Ystep],'b-','LineWidth',2); hold on
plot([0 0],[-Ystep -2*Ystep],'r-','LineWidth',2); hold on
plot([0 X],[-2*Ystep -2*Ystep],'b-','LineWidth',2); hold on
plot([X X],[-2*Ystep -3*Ystep],'r-','LineWidth',2); hold on
plot([X 0],[-3*Ystep -3*Ystep],'b-','LineWidth',2); hold on
plot([0 0],[-3*Ystep -4*Ystep],'r-','LineWidth',2); hold on
...
Any help?
Many thanks, Mo

回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by