clc,close,clear;
File1 = fopen('Set9_1.txt');
Set9_1 = fscanf(File1,'%f',200);
dt = 1;
T = 1:dt:200;
step_resp = Set9_1;
imp_resp = [diff(step_resp)./dt; 0];
Fs = 1/dt;
freq = logspace(-3,log10(Fs/3),100);
b = imp_resp';
a = [1 zeros(1,length(imp_resp)-1)];
[g,p] = dbode(b,a,dt,2*pi*freq);
p = p-p(1);
static_gain = g(1);
fc = interp1(p,freq,-90);
wc = 2*pi*fc;
mod_at_fc = interp1(freq,g,fc);
Q = mod_at_fc/(static_gain);
num = [0 0 static_gain];
den = [1/wc^2 1/(wc*Q) 1];
[g_id,p_id] = bode(num,den,2*pi*freq);
figure(2),
subplot(2,1,1),loglog(freq,g,'b',freq,g_id,'r');grid
title('Sys TF');
ylabel('magnitude')
legend('measure','model')
subplot(2,1,2),semilogx(freq,p,'b',freq,p_id,'r');grid
ylabel('phase (°)')
xlabel('Frequency (Hz)')
legend('measure','model')
axis([min(freq) max(freq) -360 0]);
sr_id = step(num,den,T);
figure(3),
plot(T,step_resp,'b',T,sr_id,'r');grid
title('Sys step response');
legend('measure','model')
1 Comment
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/657908-estimating-a-second-order-transfer-function-for-a-over-damped-second-order-system#comment_1154523
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/657908-estimating-a-second-order-transfer-function-for-a-over-damped-second-order-system#comment_1154523
Sign in to comment.