Amplitude scaling applying fft of iddata object
19 次查看(过去 30 天)
显示 更早的评论
When I compute fft of a signal manually, I get amplitudes of the signal correct, but if I create an iddata object and compute fft(iddata), then the amplitudes are somehow scaled. Does anyone know to get the correctly scaled amplitudes using fft(iddata)?
Here an example:
freq=100; %Hz
Period=1/freq;
Ts = 0.05*Period; % Sampling time
Fs = 1/Ts; % Sampling frequency
t=0:Ts:11*Period;
t(end)=[];
L = length(t); % Length of signal
S=10+cos(2*pi*freq*t+44/180*pi); % signal generation
figure
plot(t,S)
hold on
xlabel('t (s)')
ylabel('S(t)')
Computing fft() of the signal I get amplitudes 10 @0 Hz and 1 @100 Hz, which perfectly matches with the generated signal:
Y = fft(S);
P2=Y/L;
P1=P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
f = Fs*(0:(L/2))/L;
figure
subplot(211)
plot(f,abs(P1))
title('Single-Sided Amplitude Spectrum of S(t)')
xlabel('f (Hz)')
ylabel('|P1(f)|')
grid on
subplot(212)
plot(f,angle(P1)/pi*180)
title('Phase S(t)')
xlabel('f (Hz)')
ylabel('Angle (deg)')
grid on
Using the iddata object, I get different amplitudes ~148 @0 Hz and ~7.42 @100 Hz:
data=iddata(S(:),[],Ts);
figure
plot(fft(data))
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Linear Model Identification 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!