简体   繁体   中英

Plotting fft data in matlab

I am analyzing ECG data using MATLAB. The data is made up of two columns, one the time in milliseconds and the other contains the volts (mV) and is imported into MATLAB from a CSV file.

I use the built-in fft function in MATLAB (ie fft(mV) ). Now that I have the transformed data, I don't know how to plot it.

I know that I need the frequency data but I'm having trouble understanding where that comes from and what the other axis even is.

When you say "the time in milliseconds", I hope you have sampled at an even interval when performing an FFT. If you have not then you have two choices.

You can interpolate the data between the points so as to "guess" where the graph would eb at the time in the time domain.

OR

You can re-sample at a regular interval. Returning the time in milliseconds is not really necessary for this as the interval must be equal, but it could functions as a validator to prove that the data is correct.

Once you have you data with a regular sampling period then you can use this to obtain the FFT.

function [ X, f ] = ctft( x, T )
% x = sample array
% T = sampling period

% X = fft amplitude
% f = frequency 

N = length(x);
X = fftshift(fft( x, N ))*( (2*pi) / N );
f = linspace( -1, 1-1/N, N)/(2*T);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM