HELP DIFFERENT LINESTYLE ON THE SAME CURVE

7 visualizaciones (últimos 30 días)
roberta perna
roberta perna el 23 de Abr. de 2019
Comentada: Matt J el 23 de Abr. de 2019
Hi everyone, I am a new entry in the group. I have a problem with a matlab plot.
I have two vectors x and y, and plot (x, y), at this point I get a curve. I would like this curve to be dashed for values of x <50 and continuous for values x> 50. how can I do?
Thank you very much for helping
  3 comentarios
Matt J
Matt J el 23 de Abr. de 2019
Editada: Matt J el 23 de Abr. de 2019
When I plot this data, however, I see something weird-looking that does not look like a function. Perhaps it is not the correct data? Or maybe x and y are interchanged?
roberta perna
roberta perna el 23 de Abr. de 2019
Editada: roberta perna el 23 de Abr. de 2019
the plot is correct. I would like that x> 50 or 60 ( continuous) and x< 50 or 60 (dashed)

Iniciar sesión para comentar.

Respuesta aceptada

Matt J
Matt J el 23 de Abr. de 2019
Editada: Matt J el 23 de Abr. de 2019
Just split x,y into two subsets and plot each subset as a separate line:
idx=x<50;
x1=x(idx); y1=y(idx);
x2=x(~idx); y2=y(~idx);
H=plot(x1,y1,'--',x2,y2,'-');
  16 comentarios
roberta perna
roberta perna el 23 de Abr. de 2019
Editada: roberta perna el 23 de Abr. de 2019
this second graph has the same y as the first one. at this point I would like continuous line in the second plot for 0.6471<y<0.797 ( extremes of the continuous line found in the first plot)
Matt J
Matt J el 23 de Abr. de 2019
I'm not sure I understand, but you can trace a line over any subset of the data using the same kind of technique,
subset=(y<0.797)&(y>0.6471);
line(x(subset), y(subset),'LineStyle','-','LineWidth',3,'Color','red')

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Introduction to Installation and Licensing en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by