フィルターのクリア

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., ...
  1 件のコメント
Maria
Maria 2014 年 12 月 14 日
Many thanks!
-Maria

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by