hello I'm trying to solve this system of second order ordinary differential equations using ode functions (not dsolve):
k1*x' + k2*y' + k3*x + k4*y = u
k5*x" + k6*y" + k7*y' + k8*y = 0
is there a way to convert this system to first order system of equations like in "odeToVectorField"? also is there a function that acts inversely? (like a "VectorFieldToode") to combine the two equations into one higher order differential equation.

 채택된 답변

Star Strider
Star Strider 2018년 10월 24일

0 개 추천

I would normally expect this to work for other systems of differential equations:
syms k1 k2 k3 k4 k5 k6 k7 k8 u x(t) y(t) Y
Dx = diff(x);
D2x = diff(Dx);
Dy = diff(y);
D2y = diff(Dy);
Eqn1 = k1*Dx + k2*Dy + k3*x + k4*y == u;
Eqn2 = k5*D2x + k6*D2y + k7*Dy + k8*y == 0;
[VF,Subs] = odeToVectorField(Eqn1, Eqn2)
odeFcn = matlabFunction(VF, 'Vars',{t, Y, u, [k1, k2, k3, k4, k5, k6, k7, k8]})
However, that code throws this error:
Error using mupadengine/feval (line 187)
Number of indeterminates exceeds the number of ODEs.
I must leave it to you to resolve that problem.

댓글 수: 3

hosein Javan
hosein Javan 2018년 10월 24일
편집: hosein Javan 2018년 10월 24일
yes, that's strange. I think this function is unable to solve it. I did some mathematical manipulation to change the form of equations to first order and it worked:
syms k1 k2 k3 k4 k5 k6 k7 k8 u Du x(t) y(t) z(t) w(t) Y
Dx = diff(x);
Dy = diff(y);
Dz = diff(z);
Dw = diff(w);
Eqn1 = Dx == z;
Eqn2 = Dy == w;
Eqn3 = k1*Dz + k2*Dw + k3*z + k4*w == Du;
Eqn4 = k5*Dz + k6*Dw + k7*w + k8*y == 0;
[VF,Subs] = odeToVectorField(Eqn1, Eqn2, Eqn3, Eqn4)
thank you! if you could, please inform mathworks to find the bug.
Star Strider
Star Strider 2018년 10월 24일
As always, my pleasure!
Actually, it is not a bug. You changed your system of differential equations, and the condition that threw the original error was no longer present.
Hi So this thread was never solved?

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

추가 답변 (0개)

카테고리

질문:

2018년 10월 24일

댓글:

2020년 11월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by