Convert transfer function to state-space models
10 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Diego Garcia
am 11 Okt. 2019
Beantwortet: Diego Garcia
am 17 Okt. 2019
I'm trying to convert a transfer function to state space model. In order to avoid the control toolbox functions since I don't have it's license.
The transfer function that I'm using is quite simple. Is the model for a heatsink temperature.
For this transfer function I have the next values for A,B,C and D.
I've tried to compare the output from the lsim() function and the equations from above but the output differs

Here's the code that I've used
P = rand(1,10)*1000;
t = 0:1:length(P)-1;
A = -400;
B = 0.5;
C = 0.6658;
D = 0;
%%%%%%%%%%%%%%%%%%%%%%%%%
%%% State space %%%
%%%%%%%%%%%%%%%%%%%%%%%%%
state_space_sys = ss(A,B,C,D);
state_space = lsim(state_space_sys,P,t);
figure
plot(t,state_space)
grid on,grid minor, title('State space')
%%%%%%%%%%%%%%%%%%%%%%%%%
%%% My function %%%
%%%%%%%%%%%%%%%%%%%%%%%%%
x(1:length(P)) = 0;
y(1:length(P)) = 0;
u = P;
for k = 1:length(u)
x(k+1) = A*x(k) + B*u(k);
y(k) = C*x(k) + D*u(k);
end
figure
plot(t,y)
grid on,grid minor, title('My function')
Is there any mistakes on the approach?
It should be quite simple, but I can't manage to find the solution.
7 Kommentare
Walter Roberson
am 16 Okt. 2019
Bearbeitet: Walter Roberson
am 16 Okt. 2019
Is there a reason not to use tf() and ss() ? That is, if you pass a tf into ss() then it will be converted.
Akzeptierte Antwort
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Time and Frequency Domain Analysis finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

