필터 지우기
필터 지우기

Plot vertical lines with time in x-axis?

조회 수: 2 (최근 30일)
Maria
Maria 2014년 12월 14일
댓글: Maria 2014년 12월 14일
Hi all,
I have plotted a signal with time in x-axis as follows:
lengthinms = datalength/fs*1000;
dt = lengthinms/datalength;
t=(0:datalength-1)*dt;
plot(t,data)
Thereafter, I have calculated the maximum of the signal in the certain time interval:
[amp, lat] = max(data(w_min:w_max));
I have tried to plot two vertical lines around the maximum value as:
line([lat-24, lat-24], [0, amp]);
line([lat+24, lat+24], [0, amp]);
If I put samples on x-axis, the lines are placed correctly in the figure. However, when I put time in x-axis, the lines are in incorrect places. Could someone please let me know how can I plot the lines in the correct places when time is put on x-axis.
Thanks, Maria

채택된 답변

dpb
dpb 2014년 12월 14일
lat is the index into the data array of the maximum location. You're not converting it to the time
t_lat=lat*dt;
line([t_lat-24, t_lat-24], [0, amp]);
etc., ...

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by