필터 지우기
필터 지우기

How can I avoid plotting zeros in data?

조회 수: 19 (최근 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개)

태그

Community Treasure Hunt

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

Start Hunting!

Translated by