Plot a vector with different colors on selected data
1 回表示 (過去 30 日間)
古いコメントを表示
Hi community,
I have a vector of 700 elements. While plotting, I want to plot first 100 points in 'Red' color and the next 100 points in 'Blue' color. Later, I want to repeat them. Is there any inbuilt function to do it?
Thanks
0 件のコメント
回答 (2 件)
madhan ravi
2019 年 8 月 7 日
No loops needed:
v = reshape(vector,100,[]);
plot(v(:,1:2:end),'r')
hold on
plot(v(:,2:2:end),'b')
6 件のコメント
darova
2019 年 9 月 8 日
Just add x data
x = linspace(0,30,700);
y = sin(x);
x1 = reshape(x,100,[]);
y1 = reshape(y,100,[]);
i1 = 1:2:size(x1,2);
i2 = 2:2:size(x1,2);
plot(x1(:,i1),y1(:,i1),'r')
hold on
plot(x1(:,i2),y1(:,i2),'b')
hold off
参考
カテゴリ
Help Center および File Exchange で Annotations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!