Amplitude scaling applying fft of iddata object

21 visualizaciones (últimos 30 días)
Alexander Avdonin
Alexander Avdonin el 7 de Feb. de 2018
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))

Respuestas (0)

Categorías

Más información sobre Linear Model Identification en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by