# Obtain Transfer Function for Bode Plot data from PLECS Software

18 views (last 30 days)
normal_user on 21 Jun 2024
Commented: Mathieu NOE on 20 Aug 2024 at 15:31
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.

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
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);
[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)');
Mathieu NOE on 20 Aug 2024 at 15:31
hello again
probelm solved ?

### Categories

Find more on Frequency-Domain Analysis in Help Center and File Exchange

R2024a

### Community Treasure Hunt

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

Start Hunting!