I have simulation data in the time domain and I need to represent them in the frequency domain.
The data have been obtained time integrating the following equation:
$m \ddot{x} + c\dot{x} + kx = A \sin{(\phi(t))}$
where $\sin{(\phi(t))}$ represents a logarithmic chirp. Therefore, since also the integrated time histories are chirps, I cannot use the FFT to transform them in the frequency-domain, but I have to do something like it was done in this answer: system response: time vs frequency. Why do I get different magnitudes?
Therefore I used the spectrogram in this way:
% Resample at a constant sampling frequency
dt = 0.0001;
t0 = time(1);
tend = time(end);
new_t = t0:dt:tend;
Fs = 1/dt;
acce_TS = timeseries(acce_cog,time);
acce_res = resample(acce_TS,new_t);
% Spectrogram
win = hamming(256);
noverlap = 0;
nfft = 512;
X = abs(spectrogram(acce_res.data, win, noverlap, nfft,Fs));
X = 2*X/sum(win);
surf(X)
And here come the problems:
1) On the time axis I have wrong values: the time history lasts $49.5 \ s$ whereas in the spectrogram plot I see values from 0 to 2000
2) The peak response should be at nearly $30 Hz$ (which is the resonance frequency of the system, given as $f_n = \sqrt{k/m}$), whereas from the spectrogarm I see it at nearly $5 Hz$
3) The amplitude of the peak of the spectrogram is a bit higher than in the time history
4) I actually need to see only the frequency-amplitude plot, not the 3D representation, so how can I do that? At the moment I am using view([90 0])
, but is there a way to plot directly the 2D plot?
EDIT: Here the plots
contourf
gives the xy plot and the colormap refers to the z right? So, if I am not mistaken, in my case I will have the time-frequency plot and the colormap will give the amplitude. But what I need is the yz plot, so frequency-amplitude $\endgroup$Et = norm(acce_res.data).^2
which gives2.3430e+7
andEf = nrom(X).^2
(before dividing it bysum(win)
) and it gives2.6687e+009
. So something is wrong $\endgroup$