Amplitude scaling applying fft of iddata object

3 ビュー (過去 30 日間)
Alexander Avdonin
Alexander Avdonin 2018 年 2 月 7 日
回答済み: Soumya 2025 年 6 月 13 日
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))

回答 (1 件)

Soumya
Soumya 2025 年 6 月 13 日
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!

カテゴリ

Help Center および File ExchangePreprocess Data についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by