How can I avoid plotting zeros in data?

28 ビュー (過去 30 日間)
Andrew Wileman
Andrew Wileman 2015 年 11 月 17 日
コメント済み: Andrew Wileman 2015 年 11 月 17 日
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

採用された回答

Thorsten
Thorsten 2015 年 11 月 17 日
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')
  1 件のコメント
Andrew Wileman
Andrew Wileman 2015 年 11 月 17 日
Brilliant, works perfectly. Once again,many thanks Thorsten.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by