Going backwards in a for loop iteration

1 view (last 30 days)
Cláudio Costa
Cláudio Costa on 13 Mar 2018
Answered: Walter Roberson on 14 Mar 2018
I have to make this for loop go backwards when it finishs by the exact simetric path it took till the end of the iterations. It has to be a for loop.
clear all;close all;clc;
A=2;
x=0:0.1:24;
x1=24:-0.1:0;
for lambda=2:0.01:6
y=A.*cos(2*pi*x/lambda);
plot(x,y,'linewidth',3);
drawnow()
end

Answers (1)

Walter Roberson
Walter Roberson on 14 Mar 2018
for lambda=fliplr(2:0.01:6)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!