Amplitude scaling applying fft of iddata object

3 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 (1)

Soumya
Soumya on 13 Jun 2025
When the fft function is applied to a time domain iddata object, the FFTs are normalized by dividing each transform by the square root of the signal length to preserve the signal power and noise level. As a result, the amplitude values obtained using fft(iddata) differ from those produced by the standard fft function. If you want the amplitudes to match those calculated using the fft function, extract the signal from the iddata object and then apply the fft:
extractData = data.OutputData;
Y = fft(extractData);
The following documentation provides more information oniddataobject and its properties:
I hope this helps!

Tags

Community Treasure Hunt

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

Start Hunting!