How can I avoid plotting zeros in data?
29 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Andrew Wileman
le 17 Nov 2015
Commenté : Andrew Wileman
le 17 Nov 2015
Hi, Once again, hoping someone may be able to help. I'm plotting data at intervals and would like to join up the peaks so it makes a nice smooth graph(please see attached diagram). At present, there are zeros between each data point, and Matlab plots these making a nasty triangulated spike for each data point. Is there anyway of just plotting the data points? Hoping someone may be able to help, Andy
0 commentaires
Réponse acceptée
Thorsten
le 17 Nov 2015
Sample data:
y = zeros(1,100); y(1:10:100) = 1 + rand(1,10);
plot(y)
hold on
Select only non-zero values for plotting:
x = 1:numel(y);
plot(x(y~=0), y(y~=0), 'r')
Plus de réponses (0)
Voir également
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!