how can i divide a plot into ranges of different length

조회 수: 2 (최근 30일)
meli-joe Abou chedid
meli-joe Abou chedid 2018년 10월 28일
편집: jonas 2018년 10월 28일
hello, i have a plot of different straight lines, and i would like to divide it into different ranges of x values, but that has different lengths so i can use these ranges in a for loop later.

답변 (1개)

jonas
jonas 2018년 10월 28일
편집: jonas 2018년 10월 28일
It's a bit unclear what you mean by the question. You could divide the set of data into segments using logical indexing. For example
x = 0:0.1:2*pi;
y = sin(x);
s{1} = x > pi;
s{2} = x <= pi;
Now you can plot the first and second part separately.
plot(x(s{1}),y(s{1}),'r',...
x(s{2}),y(s{2}),'b')
It's also trivial to access the different segments in a loop.

카테고리

Help CenterFile Exchange에서 Graphics Objects에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by