Iterative approach for plot function

1 view (last 30 days)
Mo
Mo on 26 Mar 2014
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

Answers (0)

Community Treasure Hunt

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

Start Hunting!