How to impose constraint in ode45 on output variable?

I have a system of this type
to solve with ode45. I already built the mass matrix (several terms of this matrix depend on the x unknowns), the unknown vector x and the f vector (several terms of this vector depend on the x unknowns). My code is something like this:
options_ODE = odeset('AbsTol',1e-6,'Mass',@MassStickFree);
[vTime,vX] = ode45(@eqLongDynamicStickFree,[0 t_fin],x0',options_ODE);
where the M matrix has been built in the MassStickFree file and the f vector in the eqLongDynamicStickFree file. I would impose that the term x(8) will satisfy a certain condition, for example x(8)=0. How can I do?

댓글 수: 5

Define xdot(8)=0 with initial condition x0(8)=0.
Best wishes
Torsten.
I tried to do in this way but the vX output calculated by ode45 has the eight column that starts with a zero value but continues with non-zero values. What is the problem?
Torsten
Torsten 2017년 9월 29일
편집: Torsten 2017년 9월 29일
If you start with x0(8)=0 and set f(8)=0 in function "eqLongDynamicStickFree", x(8) will remain zero in the course of the calculation. If this is not the case, we will have to see more of your code.
Or does your mass matrix differ from the one you pasted above ?
Best wishes
Torsten.
The mass is exactly that one. The problem is that x (7) and x (8) are related because xdot (8)=x (7). I would impose that both x (8) and x (7) are zero. I tried to set
x (7)=0
x (8)=0
And to set in the function file
f (8)=0
But in this way, only the x (8) variable is zero after calculation. I also tried to define, in the mass matrix
M (7,7)=0
But in this case no result is produced (matrix is singular).
What's wrong about setting x0(8)=0, f(8)=0 and leave everything else unchanged ?
Best wishes
Torsten.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Programming에 대해 자세히 알아보기

질문:

2017년 9월 28일

댓글:

2017년 9월 29일

Community Treasure Hunt

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

Start Hunting!

Translated by