Borrar filtros
Borrar filtros

Customize the x-axis of hht plot

3 visualizaciones (últimos 30 días)
Sujata Dhar
Sujata Dhar el 26 de En. de 2024
Comentada: Star Strider el 26 de En. de 2024
For the following hht plot, I want to customize datetime values for 501 data points in x-axis instead of default time values. The datetime values should start from 01-01-1995.
t = 0:0.01:5;
signal = sin(2*pi*2*t) + sin(2*pi*5*t) + randn(size(t));
imf = emd(signal);
% Plot HHT spectrum
hht(imf, 1/mean(diff(t)), 'FrequencyLimits', [0 5]);
% Customize plot labels and title
xlabel('Time');
ylabel('Frequency (Hz)');
title('Hilbert-Huang Transform (HHT) Spectrum');

Respuesta aceptada

Star Strider
Star Strider el 26 de En. de 2024
Putting 501 datetime x-ticks would be impossible to read, at least with this example. This creates all of them, nowever only uses 24 for obvious reasons.
Make appropriate changes to use the ones you want —
t = 0:0.01:5;
signal = sin(2*pi*2*t) + sin(2*pi*5*t) + randn(size(t));
imf = emd(signal);
% Plot HHT spectrum
hht(imf, 1/mean(diff(t)), 'FrequencyLimits', [0 5]);
Ax = gca;
xt = Ax.XTick;
N = 501;
xtime = linspace(min(xt), max(xt), N);
DT = datetime(1995,1,1) + years(xtime);
DT.Format = 'dd-MMM-yyyy';
xtnew = linspace(min(xt), max(xt), numel(xt)*4);
xtlnew = linspace(min(DT), max(DT), numel(xt)*4);
Ax.XTick = xtnew;
Ax.XTickLabel = compose('%s',xtlnew);
% Customize plot labels and title
xlabel('Time');
ylabel('Frequency (Hz)');
title('Hilbert-Huang Transform (HHT) Spectrum');
.
  2 comentarios
Sujata Dhar
Sujata Dhar el 26 de En. de 2024
Thank you.
Star Strider
Star Strider el 26 de En. de 2024
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by