Determine the output of the given Block diagram

11 visualizzazioni (ultimi 30 giorni)
Hi,
I have calculated by hand the output of the given block diagram Y(z), in Z-Domain. T=1 sec.
I get as result: Y(z)=4z/[3(z-1)^2]
I want to calculate the same result with matlab. Therefore I have written the following matlab script:
clear all
clc
s = tf('s');
% model Gp(s)
Gp = 2/s;
H = s;
% close-loop transfer function in continuous domain
Tc = feedback(Gp,H);
% model Y(s)
Y = Tc*(2/s);
%% continuous to discrete transformation
T = 1; % sampling time 1 sec
Y_z = c2d(Y,T,'zoh')
But with matlab I receive as result:
Y_z = (0.6667 z + 0.6667)/(z^2 - 2 z + 1)
So my question is, is my matlab code wrong? Can I define with the matlab command c2d also the location where the sampler is placed?
Thank you!

Risposta accettata

Paul
Paul il 9 Ott 2021
Modificato: Paul il 9 Ott 2021
Not clear how that Matlab code would mimic the by-hand solution without seeing the by-hand solution. But I really doubt that it does. Did your by-hand solution solve for the Y(s) by ignoring the sampler and then discretizing the result?
I solved the problem by hand and then evaluated it in Matlab and got the same result as your by-hand solution. If you post your by-hand solution we can probably figure out how to implement it in Matlab.
  3 Commenti
Paul
Paul il 10 Ott 2021
Excellent (but replace the 5 with an s!).
Let's use the zpk forms instead of tf forms to make it easier to follow.
First define the transform variables:
s = zpk('s');
T = 1; % sample time is T = 1 as in the notes
z = zpk('z',T);
% define the continuous plant
Gs = 2/s
Gs = 2 - s Continuous-time zero/pole/gain model.
Now to discretize the combination of the plant and the ZOH, we do exactly as in your notes, and use the 'impulse' method of c2d on G(s)/s
Gz = (1 - inv(z))*c2d(Gs/s,T,'impulse')
Gz = 2 z (z-1) --------- z (z-1)^2 Sample time: 1 seconds Discrete-time zero/pole/gain model.
Gz(z) has some pole-zero cancellations, so we can get rid of those
Gz = minreal(Gz)
Gz = 2 ----- (z-1) Sample time: 1 seconds Discrete-time zero/pole/gain model.
Because G(s) is preceded by a ZOH, it's easier (and clearer?) to do
Gz = c2d(Gs,T,'zoh')
Gz = 2 ----- (z-1) Sample time: 1 seconds Discrete-time zero/pole/gain model.
Now we have to operate on the product G(s)*H(s). Again, this product is preceded by the ZOH, so
Hs = s;
GHz = c2d(Gs*Hs,T,'zoh')
GHz = 2 (z-1) ------- (z-1) Sample time: 1 seconds Discrete-time zero/pole/gain model.
In this case we still have a pole-zero cancellation to deal with because nothing in the above operations "knew" to cancel the s in the numerator of Hs with the s in the denominator of Gs. So we can apply minreal to the output, but it's probaby cleaner to apply minreal to the input
GHz = c2d(minreal(Gs*Hs),T,'zoh')
GHz = 2 Static gain.
Now compute the transfer function:
YoverR = Gz/(1+GHz)
YoverR = 0.66667 ------- (z-1) Sample time: 1 seconds Discrete-time zero/pole/gain model.
Define the reference input
Rs = 2/s;
At this point, all that's left to do is compute Rz using c2d, keeping in mind that Rz is NOT preceded by a ZOH, and mulitply it by the transfer function to yield Yz.
Mark S
Mark S il 10 Ott 2021
Modificato: Mark S il 10 Ott 2021
"Excellent (but replace the 5 with an s!)." Yes you are right.
I got it now, thank you very much! It is not so easy to do this calculation with matlab. But now I have understood it.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su General Applications in Help Center e File Exchange

Prodotti


Release

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by