Amplitude scaling applying fft of iddata object

25 views (last 30 days)
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))

Answers (0)

Categories

Find more on Linear Model Identification in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!