Borrar filtros
Borrar filtros

How to trim(remove) plot

27 visualizaciones (últimos 30 días)
AhyounLee
AhyounLee el 3 de Abr. de 2021
Comentada: AhyounLee el 4 de Abr. de 2021
I should remove yellow there, and get a maximum of x (when y = 0)
and there's no x-intercept
I tried :
if y < 0, y = [] else plot(x, y)
mask = (y<0) cla(mask)
interp1(y, x, 0) => it comes to zero
but any of them didn't work.
if I can cut off that part, I can get the answer : [ k, l ] = find(x==max(x)) x_int = [ max(x) , y(k, l) ] .
How can I trimming that part?

Respuesta aceptada

DGM
DGM el 3 de Abr. de 2021
Editada: DGM el 3 de Abr. de 2021
Try something like this:
x=0:300;
y=-0.008*x.^2 + 2*x + 1.5;
y(y<0)=NaN;
Anything that's NaN won't be plotted.
Alternatively, you can do it the way you were trying:
mask=y>=0;
y=y(mask);
x=x(mask);
and then your intercept finding method should work.
intercept=[x(end) y(end)]
Intercepts could also be found symbolically.
  1 comentario
AhyounLee
AhyounLee el 4 de Abr. de 2021
OMG THX YOU
It really helped me thanks

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by