0

I have a problem using MATLAB for a dynamics problem. The problem is how to code in MATLAB, not how to solve the equation. I'm fairly new to MATLAB.

I have 2 equations of motion like

DDx_c =

((kx_c - (m_p(2Dtheta^2lsin(theta) - (2lcos(theta)((m_psin(2theta)Dtheta^2l^2)/2 + (m_psin(2theta)l^2)/2 - gm_psin(theta)l + F - b_cx_c))/(I + l^2m_pcos(theta)^2)))/2)(I + l^2m_pcos(theta)^2))/(l^2m_p^2cos(theta)^2)

and

DDtheta =

-((m_c + m_p)(F - b_cx_c + (l^2m_psin(2theta))/2 + (Dtheta^2l^2m_psin(2theta))/2 - glm_psin(theta) + (lm_pcos(theta)(- lm_psin(theta)Dtheta^2 + kx_c))/(m_c + m_p)))/(l^2m_p^2*cos(theta)^2)

My problem is that i would like to have these equations on State Space form, in order to generate a transfer function. My problem is, that i'm not able to separate the expressions in the equation. It could be done by hand ofcause, but i would realy like this program to be generic

Could a solution be to convert the equation to a string(char array), and copy the expressions separated by '+' and '-' to some new variables, like it could be done in C++. I'm just not sure how to do it.

  • Why do you want to apply methods for linear DE to a DE system that is heavily non-linear? – Lutz Lehmann Apr 06 '22 at 15:05
  • Is this something like a spring coupled with a fulcrum? If these expressions are CAS generated, please apply `simplify` to them. In most cases a compact formulation can be found directly from the terms in the Lagrange functional or the Euler-Lagrange equations. Most transformations like linearization can also be performed more comfortably in this semi-solved state. – Lutz Lehmann Apr 06 '22 at 15:19

0 Answers0