How to draw only a part of a known curve?

조회 수: 8 (최근 30일)
ErikJon Pérez Mardaras
ErikJon Pérez Mardaras 2020년 11월 10일
댓글: ErikJon Pérez Mardaras 2020년 11월 25일
I have made this
The blue plot, is a curve defined like this:
curve=[xco0 xco1 xco2 xco3 xco4 xco5 xco6 xco7 xco8;yco0 yco1 yco2 yco3 yco4 yco5 yco6 yco7 yco8];
Which each x and y components, are its known coordinates. Each one has a lot of values in it.
I also have pointA and pointB, which are points of the curve which coordinates are known:
pointA=[ax;ay];
pointB=[bx;by];
The issue here is that I would like to draw only the part of the curve that is between those two points, or to colour the curve as white the rest of the curve that is not between pointA and pointB, which is the same thing in fact.
How can I do that?

답변 (1개)

Fangjun Jiang
Fangjun Jiang 2020년 11월 10일
x=1:0.1:10;
y=sin(x);
index=and(x>3, x<6);
plot(x(index),y(index))
  댓글 수: 10
Fangjun Jiang
Fangjun Jiang 2020년 11월 25일
In this case, index=and(y>Ya, y<Yb) is sufficient. It is due to the fact that x values exceed Xb and then comes back. Same thing could happen to y values. It is a math problem, not a MATLAB problem. You need to consider different and all the cases of your curves.
Just like your figure illustrated, index1=and(y>Ya,y<Yb) gives you the area between two purple dash lines. index2=and(x>Xa,x<Xb) gives you the area between two orange dash lines. index=and(index1, index2) gives you the rectangel area between those four dash lines.
ErikJon Pérez Mardaras
ErikJon Pérez Mardaras 2020년 11월 25일
Thanks for your reply.
But just because of that, I am looking for a general way of doing it, not a particular way that works only for a particular curve. Is there any?

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

카테고리

Help CenterFile Exchange에서 Fit Postprocessing에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by