Question for solving ODE using one function.

Hello.
I am trying to solve ODE problems, and have a question.
X = distance
X' = velocity ( X(1) )
X'' = acceleration ( X(2) )
P = pressure ( X(3) ).
function dxdt = test(t,x)
% X = distance
dxdt = [ x(2); % X' = Velocity
-x(2) - (C2 + (x(3) - P2)) * x(1) + (C1 - x(3)) ; % X'' = acceleration
1 / x(1) - 1/x(1) * x(2) ]; % Here, should be "P"(pressure), but I consider "X(3)" as P.
% P' is a function of X, X'.
% Is it wrong approach?
P' = 1/x - 1/x*x'
Is there any method for solving X, X', X'', P' together using one function?
A good adviser told me to use "syms". I understood.
But, I want to know another ways, if there are.

2 Kommentare

Torsten
Torsten am 9 Apr. 2019
Bearbeitet: Torsten am 9 Apr. 2019
If the three listed equations are correct to get position, velocity and pressure (what I can't tell) - what's the problem ?
M_king
M_king am 10 Apr. 2019
Sorry. I was confused about structure, but thanks to you I knew it.
Thank you :)

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Jan
Jan am 9 Apr. 2019

0 Stimmen

The standard approach would be:
distance: X(1)
velocity: X(2)
accleration: X(3)
pressure: X(4)
Then you can evaluate the derivatives inside the function to be integrated.
I do not know, what "P2" should be or what your problem is.

1 Kommentar

M_king
M_king am 10 Apr. 2019
Sorry to bother you.
Your answer helped me organize ODE function.
Thanks!

Melden Sie sich an, um zu kommentieren.

Gefragt:

am 9 Apr. 2019

Kommentiert:

am 10 Apr. 2019

Community Treasure Hunt

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

Start Hunting!

Translated by