how to omit zero values while plotting the graph
307 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
could anyone tell me how to omit zero values while plotting the graph.
0 comentarios
Respuestas (1)
dpb
el 6 de Abr. de 2018
Editada: dpb
el 6 de Abr. de 2018
A)
yplot=y; % make a copy of the data specifically for plotting
yplot(yplot==0)=nan; % replace 0 elements with NaN
plot(x,yplot)
will return broken lines between locations which contain zero in yplot
B)
isNZ=(~y==0); % addressing logical array of nonzero elements
plot(x(isNZ),y(isNZ)) % plot only the subset
will be solid line just without those points that were zero
1 comentario
Ayman Ahmed
el 5 de Ag. de 2021
Many thanks. I was struggling with something like this but this code helped me too much
Ver también
Categorías
Más información sobre 2-D and 3-D 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!