plotting frequency response of data in matlab

Hi all,
I am trying to plot frequency response for the attached data. I can plot its time domain, However I am not able to plot the frequency response. Can anyone help please.
Regards
Shirin

 Respuesta aceptada

Star Strider
Star Strider el 28 de Oct. de 2020

1 voto

There is only one column of data, that I assume are the independent variable. You cannot plot its frequency response without an associated time vector (vector of sampling instants). This is important with respect to knowing if the sampling intervals are constant (they can be resampled to constnt samplilng intervals if not), since that is required for all signal processing applications, including the Fourier transform. The time vector is required in order to calculate the frequency vector (independent variable) in the fft plot.

6 comentarios

shirin
shirin el 28 de Oct. de 2020
Thanks for your answer. The sampling frequency is Fs=2.5e9. As you are saying it is not possible to get frequency response of this data?
Regards
Shirin
If you know that it was regularly-sampled, then knowing the sampling frequency would be enough to calculate a fft from it.
Try this:
T1 = readtable('preditest.csv');
Fs=2.5e9;
Fn = Fs/2;
s = T1.Var1;
snan = nnz(isnan(s))
s = fillmissing(s,'linear');
L = numel(s);
t = linspace(0, L, L)/Fs;
figure
plot(t, s)
grid
xlabel('Time')
ylabel('Signal')
FTs = fft(s-mean(s))/L;
Fv = linspace(0,1,fix(L/2)+1)*Fn;
Iv = 1:numel(Fv);
figure
plot(Fv, abs(FTs(Iv))*2)
grid
xlabel('Frequency')
ylabel('Amplitude')
There are 100 NaN values that I interpolated using fillmissing. The code is straightforward, with ‘Fv’ being the frequency vector for the plot (and other analyses if you choose to do them), and ‘Iv’ the index vector for a one-sided Fourier transform plot. It looks to me like a passband-filtered signal.
shirin
shirin el 28 de Oct. de 2020
Editada: shirin el 28 de Oct. de 2020
Thank you for your reply. could you please explain what is the variable name (Var1) for?
Warning: Variable names were modified to make them valid MATLAB identifiers. The original names are saved in
the VariableDescriptions property.
Error using DAC (line 4)
Unrecognized variable name 'Var1'.
Many thanks
Shirin
I use the readmatrix function to read your file so that I can understand whatever the column headers are. Yours does not have any, so ‘Var1’ is the only column that exists. Use the file you posted and there should be no problem.
Using:
s = T1{:1};
with the file you posted will also work, and avoids the variable name incompatibility.
If you want to use a different file, attach it so that I can change my code to work with it.
shirin
shirin el 28 de Oct. de 2020
Problem solved! Thanks a lot.
Many Thanks
Shirin
Star Strider
Star Strider el 29 de Oct. de 2020
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre MATLAB en Centro de ayuda y File Exchange.

Preguntada:

el 28 de Oct. de 2020

Comentada:

el 29 de Oct. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by