MATLAB Answers

Obtaining a transfer function from tfestimate

139 views (last 30 days)
Arnou Verfaillie
Arnou Verfaillie on 30 Jul 2015
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);
figure('units','normalized','outerposition',[0 0 1 1]);
subplot(2,1,1) % Rij, Kolom, Figuurnummer
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

Answers (1)

Arkadiy Turevskiy
Arkadiy Turevskiy on 4 Aug 2015
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
% estimate a transfer function with 2 poles and 1 zero
% tune a PID Controller for the estimated transfer function
% compute a closed-loop transfer function
% plot closed-loop step response

Community Treasure Hunt

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

Start Hunting!