Plotting data created from a for loop
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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
Respuestas (0)
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!