need to plot multiple column array pairs in a matrix against each other

6 ビュー (過去 30 日間)
Brandon burns
Brandon burns 2021 年 6 月 22 日
コメント済み: Brandon burns 2021 年 6 月 22 日
I have a matrix made up of 55 column arrays I want to represent the data by plotting 2 column arrays against each other. Every 5th and 6th column array is a pair that I want to plot on the same plot. However my y-variable is only selecting the first one and is then plotting against that single array against each x variable array. I included my for loop below.
figure;
hold on
for h= 4:6:size(percentIMPS100mw,2),
for i= 5:6:size(percentIMPS100mw,2)
end
plot(percentIMPS100mw(:,h),percentIMPS100mw(:,i));
end
legend(LegendCellD,'location','northwest','NumColumns',3)
title('Nyquist Plot Device with 100 mW DC')
xlabel('Real Photocurrent(A)')
ylabel('Imaginary Photocurrent(A)')

回答 (1 件)

Cris LaPierre
Cris LaPierre 2021 年 6 月 22 日
編集済み: Cris LaPierre 2021 年 6 月 22 日
Your for loop is not written correctly. The 'end' before your plotting code means the inner loop will run incrementing i but not doing anything. Once that finishes, i is at the final value, and then it creates the plot.
You probably do not want nested for loops. The nested loops mean that every x vector is plotted against every y vector. It sounds like instead you want to just plot x against its paired y in the next column. You only need a single loop for that. Or just use indexing.
figure;
h = 4:6:size(percentIMPS100mw,2);
i = 5:6:size(percentIMPS100mw,2);
plot(percentIMPS100mw(:,h),percentIMPS100mw(:,i));
legend(LegendCellD,'location','northwest','NumColumns',3)
title('Nyquist Plot Device with 100 mW DC')
xlabel('Real Photocurrent(A)')
ylabel('Imaginary Photocurrent(A)')
  1 件のコメント
Brandon burns
Brandon burns 2021 年 6 月 22 日
Thank you for your assistance that solved my problem perfectly.

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

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by