Plot function adding line from last point in row to origin
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Radhika Kulkarni
el 23 de Feb. de 2021
Comentada: Walter Roberson
el 27 de Feb. de 2021
Hello,
I currently have a plot that looks like this:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/529099/image.png)
and I am trying to remove the line that is connecting the last node in the row to the origin. I know this question has been asked before but I was unable to use the answers to solve my problem. I tried sorting the data and tried stating LineStyle to none but it didn't work. Here is what I have so far:
plot(transpose(x_nudged),transpose(y_nudged),'-')
x_nudged(x_nudged==0)=nan;
y_nudged(y_nudged==0)=nan;
1 comentario
Walter Roberson
el 23 de Feb. de 2021
Remember that changing your data after you plot is not going to affect your plot.
Respuesta aceptada
Walter Roberson
el 23 de Feb. de 2021
In order to see that plot with multiple lines, your y_nudged must be 2D. The following code takes that into account.
xt = x_nudged.';
if isvector(xt)
xt(end) = [];
else
xt(end,:) = [];
end
yt = y_nudged.';
if isvector(yt)
yt(end) = [];
else
yt(end,:) = [];
end
plot(xt, yt);
7 comentarios
Walter Roberson
el 27 de Feb. de 2021
xt = x_coor.';
yt = y_adj.';
plot(min(xt, 15), yt)
Más respuestas (0)
Ver también
Categorías
Más información sobre Line Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!