Going backwards in a for loop iteration

조회 수: 1 (최근 30일)
Cláudio Costa
Cláudio Costa 2018년 3월 13일
답변: Walter Roberson 2018년 3월 14일
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

답변 (1개)

Walter Roberson
Walter Roberson 2018년 3월 14일
for lambda=fliplr(2:0.01:6)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by