need to plot multiple column array pairs in a matrix against each other
14 views (last 30 days)
Show older comments
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)')
0 Comments
Answers (1)
Cris LaPierre
on 22 Jun 2021
Edited: Cris LaPierre
on 22 Jun 2021
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)')
See Also
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!