Obtain Transfer Function for Bode Plot data from PLECS Software
4 views (last 30 days)
Show older comments
I have some bode plot data in an excel sheet which contains following columns.
Frequency / Hz Am1:Measured current Am1:Measured current
I have a range of values under each of this columns, I am interested in finding the transfer function that can generate similar bode plot.
Is this possible? If yes, how can I achieve it using MATLAB?
Attaching the CSV and the original bode plot here. Bode plot was generated using PLECS software.
0 Comments
Answers (1)
Mathieu NOE
on 25 Jun 2024
hello
If you have the signal processing toolbox, you can use invfreqs or invfreqz to identify a transfer function
here I used invfreqs to generate a continuous time model (transfer function) , that I then converted to dicrete model (fyi)
you can try to adapt the numerator and denominator order to find the best match (with minimal order)
NB that your data are a bit coarse , frequency resolution is not great , especially to have a good estimate of the poles damping / frequency
data = readmatrix('plecsbode_og.csv');
freq = data(:,1);
mod_dB = data(:,2);
phas_deg = data(:,3);
Mag = 10.^(mod_dB/20); % convert dB to linear magnitude
Response = Mag.*exp(1j*pi/180*phas_deg); % Complex Vector
Ts = 0.5/(2*(max(freq)));
Fs = 1/Ts;
% TF design
NA = 6;
NB = NA-2;
W = 2*pi*freq;
[num,den] = invfreqs(Response,W,NB,NA,[],100);
hverif = freqs(num,den,W);
% convert to SS
[A,B,C,D]=tf2ss(num,den);
[Ad,Bd,Cd,Dd] = c2dm(A,B,C,D,Ts,'matched');
SYS = ss(Ad,Bd,Cd,Dd,Ts);
[M,P] = bode(SYS,W);
M = squeeze(M);
P = squeeze(P);
P = wrapTo180(P);
figure(1)
subplot(2,1,1),semilogx(freq,20*log10(Mag),'b',freq,20*log10(abs(hverif)),'r',freq,20*log10(M),'c');
legend('data','TF ','SS ');
xlabel('Frequency (Hz)');
ylabel('modulus (dB)');
subplot(2,1,2),semilogx(freq,wrapTo180(phas_deg),'b',freq,180/pi*(angle(hverif)),'r',freq,(P),'c');
legend('data','TF ','SS ');
xlabel('Frequency (Hz)');
ylabel('modulus (dB)');
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!