Convert discrete sys to continuous sys using delays using linear-fractional transformation (LFT)
Show older comments
Hi,
I am trying to create a function that reutrns the continuous time MIMO transfer function of a discrete time sys. Howevee, for some reason although the bodeplot of the continuous system provides the same magnitude magnitude as the discrete sys, the phase angle seems to be mirrored at 0 deg. The function that I would like support is called d2c_exact and is given below.
Could someone figure out what I might be doing wrong? Thanks.
NOTE: I would like a solution where matrices operations are visible and not through matlab functions that obfuscate the process.
% EXAMPLE CODE %
% Declare MIMO matrices A,B,C,D
A = [-0.31261936441776167,0.28772503446055314;0.04760617923328707,0.8887042134058204];
B = [-0.607364659998142,-1.56763974476322,0.5900308503812629;1.4606427684802321,-1.6261530164028424,-0.8222697125090287];
C = [-0.004231925948322231,0.6979760136195045;-0.6958350856345005,-1.5121349753857836];
D = [-1.9523633596883074,-1.4728789255615329,0.14037581452786482;0.22729522014518927,1.2609066299547338,2.830197741550703];
% Define delay of 1 s
Ts = 1;
sys = ss(A,B,C,D,Ts);
% Discrete system
Pd = sys;
% Function that is the topic of the question
Pdc = d2c_exact(sys);
% Matlab equivalent function
Pc = d2c(sys);
% Create plots
wd = logspace(-2,2,200);
opts = bodeoptions;
opts.FreqUnits = 'rad/s';
opts.FreqScale = 'log';
opts.MagUnits = 'abs';
opts.MagScale = 'log';
opts.PhaseUnits = 'deg';
opts.Grid = 'on';
figure
bodeplot(Pd,wd,'b',opts)
hold on
bodeplot(Pdc,wd,'y',opts)
bodeplot(Pc,wd,'r--',opts)
hold off
h = get(gcf,'Children');
xline(h(2),fs/2,'k--');
xline(h(3),fs/2,'k--');
legend('Pd(z)','Pd(s)*inv(ZOH(s))','Pd(z) (ZOH sampling)','Nyquist freq. (fs/2)')
function sysc = d2c_exact(sysd)
nx = size(sysd.A,2);
s=tf('s');
Ts = sysd.Ts;
[A,B,C,D] = ssdata(sysd);
ZOH = exp(-Ts*s); % Transfer function of delay
M = append(ZOH,ZOH);
LR = M - ss(A + eye(nx));
sysc = C*feedback(eye(nx), LR)*B + D;
end
Accepted Answer
More Answers (1)
Is this what you are getting:
% EXAMPLE CODE %
% Declare MIMO matrices A,B,C,D
A = [-0.31261936441776167,0.28772503446055314;0.04760617923328707,0.8887042134058204];
B = [-0.607364659998142,-1.56763974476322,0.5900308503812629;1.4606427684802321,-1.6261530164028424,-0.8222697125090287];
C = [-0.004231925948322231,0.6979760136195045;-0.6958350856345005,-1.5121349753857836];
D = [-1.9523633596883074,-1.4728789255615329,0.14037581452786482;0.22729522014518927,1.2609066299547338,2.830197741550703];
% Define delay of 1 s
Ts = 1;
sys = ss(A,B,C,D,Ts);
% Discrete system
Pd = sys;
% Function that is the topic of the question
Pdc = d2c_exact(sys);
% Matlab equivalent function
Pc = d2c(sys);
% Create plots
wd = logspace(-2,2,200);
% Sampling freq:
fs=1e3;
figure
OPTs = bodeoptions;
OPTs.Grid = 'on';
OPTs.FreqScale = 'linear';
OPTs.Title.String = 'Bode Plot of Transfer Function';
bodeplot(Pd,wd,'b',OPTs)
hold on
bodeplot(Pdc,wd,'y',OPTs)
bodeplot(Pc,wd,'r--',OPTs)
hold off
h = get(gcf,'Children');
xline(h(2),fs/2,'k--');
xline(h(3),fs/2,'k--');
legend('Pd(z)','Pd(s)*inv(ZOH(s))','Pd(z) (ZOH sampling)','Nyquist freq. (fs/2)')
function sysc = d2c_exact(sysd)
nx = size(sysd.A,2);
s=tf('s');
Ts = sysd.Ts;
[A,B,C,D] = ssdata(sysd);
ZOH = exp(-Ts*s); % Transfer function of delay
M = append(ZOH,ZOH);
LR = M - ss(A + eye(nx));
sysc = C*feedback(eye(nx), LR)*B + D;
end
Categories
Find more on Time and Frequency Domain Analysis 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!


