Clear Filters
Clear Filters

Time domain to Frequncy domain signal conversion

3 views (last 30 days)
This is my program to generate time-amplitde ECG signal, now i want to convert this output signal into frequency-amplitude domain. I tried using FFT technique but it is invalid taking fft(x,y). Please Help
A=dlmread('samples (7).csv',',',2,0);
x= A(2:1:14761 ,1);
y= A(2:1:14761 ,2);
figure;
%z=f(x,y);
hold on;
z=plot(x,y);
xlabel('Time(sec)')
ylabel('Amplitude(mV)')
axis tight;
grid on;

Answers (1)

Star Strider
Star Strider on 27 Feb 2019
Use the Signal Processing Toolbox spectrogram (link) function to do time-frequency analysis.
  2 Comments
vandana sharma
vandana sharma on 27 Feb 2019
i do not want to do the time-frequency analysis, i want to convert/plot the same time-ampltude domain signal into frequency-amplitude domain.
Star Strider
Star Strider on 27 Feb 2019
Try this:
filename = 'samples (7).csv';
[D,S] = xlsread(filename);
t = D(:,1);
EKG = D(:,2);
figure
plot(t, EKG)
grid
L = numel(t); % Data Row Size
QF = std(diff(t)); % Check For Non-Uniform Sampling
tr = linspace(min(t), max(t), L); % Time Vector For Resampling
EKGr = resample(EKG, tr); % Resampled EKG
Ts = mean(diff(t)); % Sampling Interval (s)
Fs = 1/Ts; % Sampling Frequency (Hz)
Fn = Fs/2; % Nyquist Frequency (Hz)
FT_EKG = fft(EKGr-mean(EKGr))/L; % Fourier Transform (Offset Corrected)
Fv = linspace(0, 1, fix(L/2)+1)*Fn; % Frequency Vector
Iv = 1:numel(Fv); % Index Vector
figure
plot(tr(1:500), EKGr(1:500))
grid
figure
plot(Fv, abs(FT_EKG(Iv)))
grid
xlim([0 50])
xlabel('Frequency (Hz)')
ylabel('Amplitude (mV)')

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!