how to omit zero values while plotting the graph

308 vues (au cours des 30 derniers jours)
Prabha Kumaresan
Prabha Kumaresan le 6 Avr 2018
Commenté : Ayman Ahmed le 5 Août 2021
could anyone tell me how to omit zero values while plotting the graph.

Réponses (1)

dpb
dpb le 6 Avr 2018
Modifié(e) : dpb le 6 Avr 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 commentaire
Ayman Ahmed
Ayman Ahmed le 5 Août 2021
Many thanks. I was struggling with something like this but this code helped me too much

Connectez-vous pour commenter.

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by