freqeuncy complex data convert to FIR filter

i have frequency domain data of plate.
i want to convert to this data to FIR filter to model my system. i heard if i want to FIR filter this filter have 2*n +1 tap (n is maximum freqeuncy)
i think i have to use ifft or invfreqz but the detail code can not access in the mathWorks please help me

 Accepted Answer

hello
here you are my friend !
tried to fit minimum size IIR filter first , then FIR coefficients are equal to impulse response to IIR
data = importdata ('plate_tf.mat');
freq = data.Hz; % frequency
frf = data.com; % FRF complex
% IIR model
Fs = 1e3;
W = linspace(0,pi,length(freq));
ind = find(freq>50 & freq <150); % frequency weighting ; data reliable between 5 and 80 Hz
WT = zeros(size(W));
WT(ind) = 1;
NB = 2;
NA = 2;
[B,A] = invfreqz(frf,W,NB,NA,WT,Fs);
% check bode plots
[H,WW] = freqz(B,A,length(frf));
figure(1),
subplot(2,1,1),plot(freq,20*log10(abs(frf)),'b',freq,20*log10(abs(H)),'r');grid
subplot(2,1,2),plot(freq,180/pi*(angle(frf)),'b',freq,180/pi*(angle(H)),'r');grid
% Impulse response
[FIR,X] = dimpulse(B,A);
samples = length(FIR);
time = 1/Fs*(1:samples);
figure(2),
plot(time,FIR,'r');grid
title('Impulse response (FIR model)')
xlabel('Time (s)');
ylabel('Amplitude')

8 Comments

Thank you. i saw you another answer while i googling. i have some questions. this output magnitude and phase plot are some different compare to original plant frequency response. why this happened? and how can i describe explicitly the original plant using IIR model or FIR model?
and i have another code converting frequency response to FIR filter please estimate this code
function ir = F_fr2ir(fr, n_filter)
fr = fr(:)
if rem(n_filter,2)
sol_pair = [fr; conj(fr(end:-1:2))]; %nfft odd
else
sol_pair = [fr; conj(fr(end-1:-1:2))]; %nttf even
end
ir = real(ifft(sol_pair));
this code make symmetry property and convert to FIR filter
Thank you
another questions is why do you put the frequency weighting?? if i want to have full frequency range, is it impossible? and the other is when i edit your previous code How to convert S-parameters (MA format) to transfer function or impulse response? - MATLAB Answers - MATLAB Central (mathworks.com) for my model, i have some unstability poles and complex error. is there a conversion rule? like length of B,A or value of ind so on....
thank you very much
i'm sorry about lot of asking...... when i want to express lot of mode of plate, summation of 2-nd order tf is needed.
so if i have data that have a lof of resonanse peak. the IIR filter order is to be more larger? is that the rule?
ㄷfrequency frange is 20~ 900 Hz and B,A is 17 and 19. magnitude is somewhat similar but i can't relaible this estimation because of phase difference. why there is some gap? and is it impossible?
hello
if you have lightly damped resonances , this correspond to a pair of complex congugated poles with light damping ; this is at the denominator of the IIR model; the FIR does not have poles , only zeros (numerator) and is not a suited method to identify accurately a lightly damped structure, or it will be very long , so not efficient if you want to use it in a simulation or control system;
from the last graph, you should plot the top grap in y log scale (so use semilogy instead of plot) and the phase difference is due to unmodelized zeroes in your model; try increase the numerator while keeping always degree of denominator >= degree numerator
Thank you very much. just one more thing..... i get best numerator and denominator. but i received
(Warning: The matrix may be close to a singular matrix or badly scaled C. Results may be inaccurate. rcond = 5.400609e-19)
error massage.
if this error is exist, my IIR model can't be used?
It still can be used if you have data and model FRFs in good match and make sure also your IIR model is stable (using isstable and impulse or step response)
the warning may be due to under or over parametrization; keep in mind to have the right amount of zeroes and poles in your model
very very Thank you......when i have some question, i will find you...... hahahah thank you

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!