So i've got an exisiting ekg signal that I have to take get the fourier transform for, and plot the phase (angle) and magnitude. My code looks like this:
x1 = 3.5*ecg(2700);
y1 = sgolayfilt(kron(ones(1,13),x1),0,21);
n = (1:30000)';
del = round(2700*rand(1));
mhb = y1(n+del);
ts = 0.00025;
t = [ts: ts: 7.5];
%plot(t,mhb)
%xlabel('Time(sec)')
%ylabel('Amp'); grid on
Xf = fft(mhb(t));
w = [-(n/2):1:(n/2)-1]*(1/(ts*n));
w = [-(n/2):1:(n/2)-1]*(1/(ts*n));
subplot(211), plot(w, fftshift(abs(Xf))), grid
subplot(212), plot(w, fftshift(angle(Xf))), grid
It's telling me this error: "Subscript indices must either be real positive integers or logicals." I'm pretty sure thats correct, unless I'm doing something completely incorrect. Any help would be appreciated.
Notice that t is real array with the values (lets look at the first few):
>> t(1:10)
ans =
0.0003 0.0005 0.0008 0.0010 0.0013 ... and so on
So the argument of your fft is mhb(t), but you are calling the values of mhb (also an array) with values of t as indices.
This gives you the error:
>> mhb(t)
Subscript indices must either be real positive integers or logicals.
So you need to do something like:
mhb(1:length(t));
Does that clear things up?