Obtain the frequency response of a time domain chirp signal 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
1) On the time axis I have wrong values: the time history lasts 45 s whereas in the spectrogram plot I see values from 0 to 2000


RTFM on surf.  You'll need to do something like surf(new_t,new_f,X) instead of just surf(X).  Your new_f should be something like 

new_f = linspace(0,Fs/2,256);


NOTE: I don't have access to matlab, and am not sure of the orientation of X. You may have to swap the parameter locations of new_t and new_f on surf.


  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?


Do something like:

plot(new_t, max(X));


You may have to do max(X') instead, depending on the orientation of X.

I'll need to think about answers to 2 &amp; 3. Watch this space.