Bode Plot to Transfer Function

37 views (last 30 days)
Muhammad
Muhammad on 27 Jul 2023
Commented: Star Strider on 28 Jul 2023
Hello, I take experimental data of my plant (Which is Atomic Force Microscopy PZT Actuator and Frame).
I have .DAT File, which contains following information Freuency (Hz), Magnitude dB, Phase Degree.
I want to estimate the transfer function of my AFM system from that bode plot, How can I do this in the MATLAB. I am not sure which order my plant is and either it is linear or non linear, I am new to the control system.
I have attached the .csv file of my data and Bode Plot image.
I

Accepted Answer

Star Strider
Star Strider on 27 Jul 2023
If you have the System Identification Toolbox, this is (relatively) straightforward, however your data requires a bit of pre-processing. Start with the idfrd function and then use tfest. (The Signal Processing Toolbox has similar functions, however I usually use the System Identification Toolbox functions for these problems).
Try this —
figure
imshow(imread('Bode Plot_AFm.JPG'))
T1 = readtable('HH8.csv')
T1 = 1001×4 table
F GdB P G ___ ____ ____ ____ 100 33.9 -110 49.4 101 34.1 -110 50.7 101 33.8 -107 48.9 102 34.2 -108 51.1 102 33.6 -105 47.8 103 34 -107 49.8 103 33.1 -111 45.2 104 33.8 -108 48.8 104 33.7 -108 48.4 105 33.5 -106 47.5 105 33.7 -106 48.5 106 33.6 -107 48 106 34 -105 50.1 107 34 -103 50 107 34.1 -103 51 108 34.2 -102 51.6
Ts = 0; % Fill With Actual Sampling Frequency
FHz = T1.F;
for k = 1:size(T1,1)-1
if FHz(k+1) == FHz(k)
FHz(k+1) = FHz(k+1)+0.5; % 'Brute Force' Interpolation
end
end
Mag = T1.G;
PhDeg = T1.P;
Response = Mag.*exp(1j*deg2rad(PhDeg)); % Complex Vector
sysfr = idfrd(Response, FHz, Ts, 'FrequencyUnit','Hz')
sysfr = IDFRD model. Contains Frequency Response Data for 1 output(s) and 1 input(s). Response data is available at 1001 frequency points, ranging from 100 Hz to 1.5e+04 Hz. Status: Created by direct construction or transformation. Not estimated.
tfsys = tfest(sysfr,18)
tfsys = -6.838e04 s^17 + 1.058e10 s^16 - 5.832e14 s^15 + 1.29e19 s^14 - 2.521e23 s^13 + 5.075e27 s^12 - 2.423e31 s^11 + 9.36e34 s^10 - 9.093e37 s^9 + 3.076e41 s^8 - 1.342e44 s^7 + 4.287e47 s^6 - 9.57e49 s^5 + 2.978e53 s^4 - 3.277e55 s^3 + 1.019e59 s^2 - 4.296e60 s + 1.372e64 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- s^18 + 2.677e05 s^17 + 4.519e09 s^16 + 3.152e14 s^15 + 1.125e18 s^14 + 8.793e22 s^13 - 3.708e26 s^12 + 2.531e30 s^11 - 2.069e33 s^10 + 8.788e36 s^9 - 4.455e39 s^8 + 1.255e43 s^7 - 4.823e45 s^6 + 8.854e48 s^5 - 2.802e51 s^4 + 3.061e54 s^3 - 8.38e56 s^2 + 4.148e59 s - 1.02e62 Continuous-time identified transfer function. Parameterization: Number of poles: 18 Number of zeros: 17 Number of free coefficients: 36 Use "tfdata", "getpvec", "getcov" for parameters and their uncertainties. Status: Estimated using TFEST on frequency response data "sysfr". Fit to estimation data: 85.98% FPE: 4.104, MSE: 3.819
figure
compare(sysfr, tfsys)
Experiment to get desired results. Having the actual sampling frequency would likely improve this.
.
  6 Comments
Muhammad
Muhammad on 28 Jul 2023
Moved: Star Strider on 28 Jul 2023
Thank You so much.
Star Strider
Star Strider on 28 Jul 2023
As always, my pleasure!

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!