Azzera filtri
Azzera filtri

Plot vertical lines with time in x-axis?

2 visualizzazioni (ultimi 30 giorni)
Maria
Maria il 14 Dic 2014
Commentato: Maria il 14 Dic 2014
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

Risposta accettata

dpb
dpb il 14 Dic 2014
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., ...

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by