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

6 次查看(过去 30 天)
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)')

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by