c2d convert to discrete time function with derivatives

8 ビュー (過去 30 日間)
Gabrielle Pineau
Gabrielle Pineau 2019 年 7 月 7 日
コメント済み: Raj 2019 年 7 月 9 日
I have the matrix:
xdot = [x(2);
(x(4)*x(6)*(p.Iyy-p.Izz)-(u(1)+u(2)+u(3)+u(4))*p.IR*x(4)...
+(p.b*p.l*(u(2)^2-u(4)^2)))/p.Ixx; %phi_dot
x(4); %theta
(x(2)*x(6)*(p.Izz-p.Ixx)+(u(1)+u(2)+u(3)+u(4))*p.IR*x(2)...
+(p.b*p.l*(u(3)^2-u(1)^2)))/p.Iyy; %theta_dot
x(6); %ksi
(x(4)*x(2)*(p.Ixx-p.Iyy)+(p.d*(u(1)^2+u(3)^2-u(2)^2-u(4)^2)))/p.Izz; %ksi_dot
x(8); %X
((p.b*(u(1)^2+u(2)^2+u(3)^2+u(4)^2))*(sin(x(1))*sin(x(5))...
+cos(x(1))*sin(x(3))*cos(x(5))))/p.mass; %X_dot
x(10); %Y
((p.b*(u(1)^2+u(2)^2+u(3)^2+u(4)^2))*(cos(x(1))*sin(x(3))*sin(x(5))...
-sin(x(1))*cos(x(5))))/p.mass; %Y_dot
x(12); %Z
((p.b*(u(1)^2+u(2)^2+u(3)^2+u(4)^2))*(cos(x(1))*cos(x(3)))-p.mass*p.g)/p.mass];
This is mathematical model of quadcopter with 12 equations (3 rotational, 3 translational degrees of freedon and their first derivatives). u is the control input (four rotors of the quadcopter).
I need to convert this model to discrete time by using c2d. However, this is not a transfer function and doesn't look like a state-space model (I can be mistaken).
Can you recommend if this model can be converted by c2d and if can, how does it look like? Should I reformulate somehow the model equations?
Thank you in advance for your answer!

採用された回答

Raj
Raj 2019 年 7 月 8 日
Ok so your question is lacking a few crucial details and possible something is not right here.
From the matrix you have given for xdot, it looks like your state vectors are:
x=[phi_integral,phi,theta_integral,theta,ksi_integral,ksi,X_integral,X,Y_integral,Y,Z_integral,Z]
but I believe and as you have mentioned in your question also, the state vectors should be
x=[phi,phi_dot,theta,theta_dot,ksi,ksi_dot,X,X_dot,Y,Y_dot,Z,Z_dot]
So, the equation you have provided probably needs to be corrected as expression for x and not xdot. Please correct me if I am wrong here.
"I need to convert this model to discrete time by using c2d. However, this is not a transfer function and doesn't look like a state-space model" : This set of ODEs can be easily converted to state space format xdot=Ax+Bu (System matrix, Input matrix etc.)
and then you can just use
ss=(A,B,C,D,Ts)
to convert your whole system to discrete state space format with sampling time as Ts. No need to use c2d unless you want to discretize individual transfer functions. Good luck!
  2 件のコメント
Gabrielle Pineau
Gabrielle Pineau 2019 年 7 月 8 日
Raj, thank you for the answer! "xdot" is just a name, as futher this matrix is used in ODE45 and then in fmincon. Could you recommend, is it possible to use the matrix in ODE45 after discretization? And what did you mean by "No need to use c2d unless you want to discretize individual transfer functions"? Thank you!
Raj
Raj 2019 年 7 月 9 日
Usually we say as per standard equation, xdot=Ax+Bu where xdot is the first derivative of state vector matrix 'x'.
1) "is it possible to use the matrix in ODE45 after discretization"- Yes you can but please read this before you proceed.
2) "No need to use c2d unless you want to discretize individual transfer functions" - What I meant is that you have a system with 4 control inputs and 12 output state vectors (assuming all are measurable). This system is represented by the standard state space form:
xdot=Ax+Bu
y=Cx+Du
Now in MATLAB
System=ss(A,B,C,D)
will give you a continuous state space model. You can discretize this full system by just using
System1=ss(A,B,C,D,Ts)
where Ts will be your sampling time. No need to use c2d here.
However if you wish to get transfer function from each input to each output, then you can use
tf(system)
which will give you a total of 48 transfer functions i.e. a transfer function from each input to each output. You can then discretize these individual transfer functions using c2d as per your need.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by