필터 지우기
필터 지우기

Simultanious for loop (two variables)

조회 수: 1 (최근 30일)
Karl
Karl 2013년 8월 15일
How do I make j = 1 when i = 2 and j = 2 when i = 3 in the loop below (that does not do this)?
a = rand(1,2);
b=rand(2,3);
myColorMap = lines(length(a));
for i = 2:3;
for j= 1:length(a);
hold on
plot(b(:,i), 'color', myColorMap((j), :));
end
end

채택된 답변

Andrei Bobrov
Andrei Bobrov 2013년 8월 15일
a = rand(1,2);
b = rand(2,3);
myColorMap = lines(length(a));
s = size(b);
for jj = 1:length(a);
hold on
plot(b(:,s(jj)), 'color', myColorMap(jj, :));
end
  댓글 수: 1
Karl
Karl 2013년 8월 15일
That worked. Thanks, Andrei!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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