필터 지우기
필터 지우기

Not enough input arguments for ode45

조회 수: 1 (최근 30일)
Akekaphop Kesavadhana
Akekaphop Kesavadhana 2024년 3월 6일
댓글: Akekaphop Kesavadhana 2024년 3월 7일
I am recieving an error for "Not enough input arguments.
Error in DoubleIP>@(t,Y,updated_state)DPIC(t,Y,updated_state) (line 175)
[time, state_values] = ode45(@(t,Y, updated_state) DPIC(t, Y, updated_state), tspan, IC);
Error in odearguments (line 92)
f0 = ode(t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 104)
odearguments(odeIsFuncHandle,odeTreatAsMFile, solver_name, ode, tspan, y0, options, varargin);
Error in DoubleIP (line 175)
[time, state_values] = ode45(@(t,Y, updated_state) DPIC(t, Y, updated_state), tspan, IC);"
This is a code snippet so certain details have been ommitted but I believe that these are the only details required for help. If more details are required I would be happy to provide them. Thank you in advance.
t0 = 0;
tf = 30;
tspan = [t0 tf];
% IC = [theta1 theta2];
IC = [x theta1 theta2 x_dot theta1_dot theta2_dot];
[time, state_values] = ode45(@(t,Y, updated_state) DPIC(t, Y, updated_state), tspan, IC);
x = state_values(:,1);
theta1 = state_values(:,2);
theta2 = state_values(:,3);
x_dot = state_values(:,4);
theta1_dot = state_values(:,5);
theta2_dot = state_values(:,6);
updated_state = [state_values(1);
state_values(2);
state_values(3);
state_values(4);
state_values(5);
state_values(6)];
function sdot = DPIC(t,Y,updated_state)
g = 9.8; % Gravitational Constant in [m/s^2]
L1 = 0.5; % Length of lower pendulum link in [m]
L2 = 0.75; % Length of upper pendulum link in [m]
m0 = 1.5; % Mass of cart in [kg]
m1 = 0.5; % Mass of lower pendulum link in [kg]
m2 = 0.75; % Mass of upper pendulum link in [kg]
l1 = (1/2)*L1; % Distance between the base of first pend. link and its center of mass
l2 = (1/2)*L2; % Distance between the base of second pend. link and its center of mass
I1 = (1/12)*m1*(L1)^2; % Moment of inertia of first pendulum link
I2 = (1/12)*m2*(L2)^2; % Moment of inertia of second pendulum link
K_lqr = [2.2361 -294.4233 7.2340 8.9417 -47.0216 -58.1944]';
desired_state = [0 0 0 0 0 0];
% u = @(time) 1;
u = @(time) -K_lqr*(updated_state - desired_state);
sdot = [ Y(2)
EQN1 (Place holders, **ignore) these equations do contain "u(t)"
Y(4)
EQN2 (Place holders, **ignore)
Y(6)
EQN3 (Place holders, **ignore)
];
end

답변 (1개)

Walter Roberson
Walter Roberson 2024년 3월 7일
[time, state_values] = ode45(@(t,Y, updated_state) DPIC(t, Y, updated_state), tspan, IC);
ode45() only has two values available to be passed: t and Y. ode45() is not going to pass in any updated_state
I'm not at all sure, but it looks like your code is expecting to use some sort of feedback mechanism -- to be given the "current" state but also to be given the "previous" state. That doesn't happen in ode45(): you are only ever given the "current" state.
  댓글 수: 4
Steven Lord
Steven Lord 2024년 3월 7일
So your differential equations looks more like the one at the top of this documentation page rather than the ones in the Types of ODEs section on this other documentation page? If so ode45 is not the right tool for the job; instead use one of the delay-differential equation solvers like dde23.
Akekaphop Kesavadhana
Akekaphop Kesavadhana 2024년 3월 7일
I am currently referencing a paper "Control Theory: The Double Pendulum Inverted on a Cart Ian J P Crowe-Wright University of New Mexico" which states that ode45 was used to generate the results and graphs for that paper. So I am attempting to go the same route. Any more advice?

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

카테고리

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

태그

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by