Plot vertical lines with time in x-axis?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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
0 comentarios
Respuesta aceptada
dpb
el 14 de Dic. de 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., ...
Más respuestas (0)
Ver también
Categorías
Más información sobre Dates and Time en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!