필터 지우기
필터 지우기

Why am I receiving an error for "odeToVectorField" when I am trying to convert second order differential equations to 1st order differential equations?

조회 수: 3 (최근 30일)
I have these three differential equations that I need to convert to first order, except the code errored and I recieved the following:
"Unable to convert the initial value problem to an equivalent dynamical system. Either the differential equations cannot be solved for the highest derivatives or inappropriate
Error in mupadengine/evalin_internal
Error in mupadengine/fevalHelper
Error in mupadengine/feval_internal
Error in odeToVectorField>mupadOdeToVectorField (line 171)
T = feval_internal(symengine,'symobj::odeToVectorField',sys,x,stringInput);
Error in odeToVectorField (line 119)
sol = mupadOdeToVectorField(varargin);
Error in DoubleIP_math (line 20)
V = odeToVectorField(eqn1_5,eqn1_4,eqn1_3)"
eqn1_5 = (m0 + m1 + m2)*diff(x,2) + (m1*l1 + m2*L2)*cos(theta1)*diff(theta1,2) + m2*l2*cos(theta2)*diff(theta2,2) - (m1*l1 + m2*L1)*sin(theta1)*(diff(theta1,1))^2 - m2*l2*sin(theta2)*(diff(theta2,1))^2 == u(t);
Unrecognized function or variable 'm0'.
% eqn1_5_f = odeToVectorField(eqn1_5)
eqn1_4 = (m1*(l1)^2 + m2*(L1)^2 + I1)*diff(theta1,2) + (m1*l1 + m2*L1)*cos(theta1)*diff(x,2) + m2*L1*l2*cos(theta1-theta2)*diff(theta2,2) + m2*L1*l2*sin(theta1-theta2)*(diff(theta2,1))^2 - g*(m1*l1 + m2*L1)*sin(theta1) == 0;
% eqn1_4_f = odeToVectorField(eqn1_4)
eqn1_3 = m2*l2*cos(theta2)*diff(x,2) + m2*L1*l2*cos(theta1-theta2)*diff(theta1,2) + (m2*(l2)^2 + I2)*diff(theta2,2) - m2*L1*l2*sin(theta1-theta2)*(diff(theta1,1))^2 - m2*g*l2*sin(theta2) == 0;
% eqn1_3_f = odeToVectorField(eqn1_3)
V = odeToVectorField(eqn1_5 ,eqn1_4, eqn1_3)
  댓글 수: 1
Akekaphop Kesavadhana
Akekaphop Kesavadhana 2024년 3월 6일
I already have defined the variables to be symbolic and the issue persisted. Any other ideas?
% syms m0 m1 m2 l1 l2 L1 L2 I1 I2 g u(t) x(t) theta1 theta2

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

채택된 답변

Sam Chak
Sam Chak 2024년 3월 6일
Previously, theta1 and theta2 were created as scalar variables when they should be functions of time.
% syms m0 m1 m2 l1 l2 L1 L2 I1 I2 g u(t) x(t) theta1 theta2
% ^^^^ ^^^^
syms m0 m1 m2 l1 l2 L1 L2 I1 I2 g u(t) x(t) theta1(t) theta2(t)
eqn1_5 = (m0 + m1 + m2)*diff(x,2) + (m1*l1 + m2*L2)*cos(theta1)*diff(theta1,2) + m2*l2*cos(theta2)*diff(theta2,2) - (m1*l1 + m2*L1)*sin(theta1)*(diff(theta1,1))^2 - m2*l2*sin(theta2)*(diff(theta2,1))^2 == u(t);
eqn1_4 = (m1*(l1)^2 + m2*(L1)^2 + I1)*diff(theta1,2) + (m1*l1 + m2*L1)*cos(theta1)*diff(x,2) + m2*L1*l2*cos(theta1-theta2)*diff(theta2,2) + m2*L1*l2*sin(theta1-theta2)*(diff(theta2,1))^2 - g*(m1*l1 + m2*L1)*sin(theta1) == 0;
eqn1_3 = m2*l2*cos(theta2)*diff(x,2) + m2*L1*l2*cos(theta1-theta2)*diff(theta1,2) + (m2*(l2)^2 + I2)*diff(theta2,2) - m2*L1*l2*sin(theta1-theta2)*(diff(theta1,1))^2 - m2*g*l2*sin(theta2) == 0;
[V, S] = odeToVectorField(eqn1_5 ,eqn1_4, eqn1_3)
V = 
S = 

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Numeric Solvers에 대해 자세히 알아보기

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by