How to turn a continuous time-y(t) array into Zero-Order-Hold and Tustin method discrete plot with different Ts

Hi, I've obtained the continuous plant of a cone-shaped-tank on Simulink. I took the data and turned into arrays both for time and y(t). I'd like to discretize both with ZOH and Tustin.
I haven't found any method yet.
Thank you in advance,
Pablo.

4 Comments

You can use MATLAB’s Control System Toolbox to convert your continuous-time model into a discrete-time model using the Zero-Order Hold (ZOH) and Tustin methods.
% Assuming 'sys' is your continuous-time system
Ts = 0.1; % Define your sampling time
% For Zero-Order Hold
sys_zoh = c2d(sys, Ts, 'zoh');
% For Tustin method
sys_tustin = c2d(sys, Ts, 'tustin');
Thanks!
Hi, unfortunately it's not a transfer function what I have, I tried that but it won't do. I have two arrays of data that I've obtained from my Simulink model, I don't know the transfer function. There's the trouble.
I have two arrays of data,
Time and y(t), I've obtained this data from my simulink via
Time = out.logsout{1}.Values.Time;
y = out.logsout{1}.Values.Data;
Another question to simplify everything would be: How can I turn this information into a transfer function, if I could do that then the problem is solved.
If you have time-series data and you want to estimate a transfer function, you can use the tfest function in MATLAB’s System Identification Toolbox. Here is a simple example:
% Assuming 'time' and 'y' are your arrays
data = iddata(y,[],Ts); % Create an iddata object, Ts is your sampling time
np = 2; % Number of poles
nz = 0; % Number of zeros
sys = tfest(data,np,nz); % Estimate transfer function
Once you have the transfer function, you can then discretize it using the Zero-Order Hold (ZOH) and Tustin methods as mentioned in the previous comments.
% For Zero-Order Hold
sys_zoh = c2d(sys, Ts, 'zoh');
% For Tustin method
sys_tustin = c2d(sys, Ts, 'tustin');
Mmm it doesn't allow me to use the tfest function with the data obtained with the iddata command. I've obtained something replacing the [] with the time, but I'm not certain the obtained data makes sense.
With the data from my system on Simulink I had the following
What the second plot means, is that the cone-shaped-cone takes about 25 seconds to empty and the dashed line is the linearized system I obtained with the Taylor expansion. The system looks a bit complex, I wish it was just a transfer function

Sign in to comment.

Answers (0)

Products

Release

R2021a

Asked:

on 12 Apr 2024

Commented:

on 12 Apr 2024

Community Treasure Hunt

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

Start Hunting!