How to run two variable simultaneously in for loops?

25 ビュー (過去 30 日間)
Taoooooooooooo
Taoooooooooooo 2019 年 6 月 1 日
コメント済み: Taoooooooooooo 2019 年 6 月 1 日
For example, i have two variable x and y, which both stand for x-axis and y axis of my plot. My code:
for k=1:17:289
for i=1:1:17
plot(175*(i-1)+1:175*i,sagittal(:,k));
hold on
end
end
I want both variable can run at the same time such that k=1 and i=1, plot; k=18 and i=2, plot......;k=273 and i=17 then plot. Therefore, all the plots will be placed in a single plot horizontally.
Can somebody help me to fix this problem?
Thank you so much!

採用された回答

Image Analyst
Image Analyst 2019 年 6 月 1 日
Try this:
k1 = 1:17:289
k2 = 1:1:17
for k= 1 : length(k1)
v1 = k1(k);
v2 = k2(k);
plot(175*(v2-1)+1:175*v2, sagittal(:,v1));
hold on
end
  1 件のコメント
Taoooooooooooo
Taoooooooooooo 2019 年 6 月 1 日
THANK YOU!! IT SEEMS WORKING WELL!!!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by