Obtaining a transfer function from tfestimate
45 views (last 30 days)
Show older comments
So i have some data read in from an excel file (attachment) and i want to make a transfer function from this data. So i've used tfestimate to calculate the phase and amplitude to plot this in a bode.
with the bode I've calculated the parameters for my potential PID. Allthough i would like to test this before I'm actually going to set the PID. So i want to simulate this. Rltool does not work because it does not have real coefficients.
Does anyone know how to make a transfer function out of my data or how to simulate this data with and without PID?
Thanks in advance!
if true
data = xlsread('RapportLijn1Waswater1.xlsx','blad1','B2000:D5000');
Ts = 1; % In seconden
Fs = 1/Ts; % Een beeld per 9 seconden
Input = data(:,2); % Setpoint
Output =data(:,1); % Processvalue
LMN = data(:,3); % Aanstuurwaarde klep in %
Fmax = Fs/2; % Max waarde tot waar bode nuttig is
%%Analyse mbv tfestimate
[TF_tfe, F_tfe]=tfestimate(LMN,Output,[],[],[],1/Ts);
A_tfe=abs(TF_tfe);
Ph_tfe=unwrap(angle(TF_tfe));
W_tfe=2*pi*F_tfe;
A_tfe_dB=20*log10(A_tfe);
Ph_tfe_deg=180/pi*Ph_tfe;
%%Afbeelden
figure('units','normalized','outerposition',[0 0 1 1]);
subplot(2,1,1) % Rij, Kolom, Figuurnummer
set(semilogx(W_tfe,A_tfe_dB,'k'),'linewidth',1.5);
line([Fs/2 Fs/2],[-100 100]) % Tot Fs/2 is bruikbare gedeelte
grid on
subplot(2,1,2) % Rij, Kolom, Figuurnummer
set(semilogx(W_tfe, Ph_tfe_deg, 'k'),'linewidth',1.5);
line([Fmax Fmax],[-500 500]) % Tot Fs/2 is bruikbare gedeelte
set(gca, 'YTick',[-180 -90 0 90 180])
grid on
%%Berekenen PID
Wpm = 0.02454;
PM = 100;
Apm = 38.19;
Wz = Wpm/2;
Kp = (10^(-Apm/20))/1.25
Td = 1/(2*Wz)
Ti = 4*Td
end
0 Comments
Answers (1)
Arkadiy Turevskiy
on 4 Aug 2015
Hi,
If you have access to System Identification Toolbox, you could use it to estimate a transfer function that you can use for simulation. For example, you could use tfest function. This function basically returns a Linear Time-Invariant system. You can use it with Control System Toolbox or in Simulink.
For example, you could do something like this:
% create iddata object by specifying output signal, input signal, and sampling time
data=iddata(output,input,sample_time);
% estimate a transfer function with 2 poles and 1 zero
sys=tfest(data,2,1);
% tune a PID Controller for the estimated transfer function
C=pidtune(sys,'pid');
% compute a closed-loop transfer function
CL=feedback(C*sys,1);
% plot closed-loop step response
step(CL);
0 Comments
See Also
Categories
Find more on Data Preparation Basics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!