Plotting data created from a for loop
조회 수: 1 (최근 30일)
이전 댓글 표시
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
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!