필터 지우기
필터 지우기

Plot a vector with different colors on selected data

조회 수: 1 (최근 30일)
Alex
Alex 2019년 8월 7일
댓글: darova 2019년 9월 8일
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

답변 (2개)

madhan ravi
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
Alex
Alex 2019년 8월 12일
@madhan: Any update? Thanks
darova
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

댓글을 달려면 로그인하십시오.


darova
darova 2019년 8월 12일
SOmething like this?

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by