Plotting data created from a for loop

1 view (last 30 days)
David Anthony
David Anthony on 23 Apr 2017
Commented: Stephen23 on 26 Apr 2017
I'm trying to plot data created from a for loop.
x1 = ns;
y1 = r;
x2 = ns2;
y2 = r2;
sz1 = 10;
sz2 = 30;
c = 'k';
scatter(x1,y1,sz1,c,'filled');
hold on;
scatter(x2,y2,sz2,c,'filled');
hold on;
line(x1,x2);
hold on;
line(y1,y2);
xlim([0.89 1.01])
ylim([0 0.8])
Where ns, r, ns2 and r2 are data created from a for loop (n=1:5).
The code words fine without the lines, plotting all the data points, but I would like to create a set colour for every n (as opposed to a gradient), and join up each x1,x2 and y1,y2 separately for every n. At the moment, the lines go crazy and try to join everything up, and I have no idea how I'd set a separate colour for every n.
How would I achieve this?
Thanks

Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!