ode45の使用の際に”入力引数が不足しています。”とエラーが出る問題に関して
Show older comments
ode45に関する質問です。
一度シンボリック計算によって
%オイラーラグランジュの運動方程式
dx = [dq; M_mat\(-CoriGrav + Q)];
オイラーラグランジュの運動方程式を計算し、ode45を使い
[t, x_ans] = ode45(@dx_function, tspan, [0 0 0 0 0 0]);
微分方程式を解くプログラムを作製したのですが
入力引数が不足しています。
エラー: dx_function (line 8)
t2 = cos(theta1);
エラー: odearguments (line 90)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
エラー: ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
エラー: pendulum_wobble (line 57)
[t, x_ans] = ode45(@dx_function, tspan, [0 0 0 0 0 0]);
とのエラーが解決出来ず困っています。
回答、宜しくお願い致します。
以下作製したコード
clear; format compact %initialize
syms z theta1 theta2
syms dz dtheta1 dtheta2
syms M I l_b % body
syms m l_p % pendulum
syms L_f(t) k_f L_r(t) k_r % leg
syms g
q = [z; theta1; theta2];
dq = [dz; dtheta1; dtheta2];
K = 0.5*M*dq(1)^2 + 0.5*I*dq(2)^2 + 0.5*m*l_p^2*(dq(2)+dq(3))^2 + 0.5*m*((dq(1)+ l_p*(dq(2)+dq(3))*sin(q(2)+q(3)))^2 + (l_p*(dq(2)+dq(3))*cos(q(2)+q(3)))^2);
U = 0.5*k_f*(q(1) - l_b*sin(q(2)) + L_f(t))^2 + 0.5*k_r*(q(1) + l_b*sin(q(2)) + L_r(t))^2 + M*g*q(1) + m*g*(q(1) + l_p*sin(q(2)+q(3)));
Q = 0;
L = K- U;
M_mat = jacobian(jacobian(L,dq),dq);
M_mat = simplify(M_mat);
CoriGrav = jacobian(jacobian(L,dq),q)*dq - jacobian(L,q).';
CoriGrav = simplify(CoriGrav);
%オイラーラグランジュの運動方程式
dx = [dq; M_mat\(-CoriGrav + Q)];
%微分方程式を解く設定
M = 3;
l_b = 0.15;
I = M*l_b^2/12;
m = 0.4;
l_p = 0.1;
g = 9.81;
k_f = 2700;
k_r = 2700;
A = 0.01;
T = 0.275;
omega = 2*pi/T;
L_f(t) = A*sin(omega*t);
L_r(t) = A*sin(omega*t + pi/2);
dx_subs = subs(dx);
matlabFunction(dx_subs,'file', 'dx_function','Vars',{t, z, theta1, theta2, dz, dtheta1, dtheta2});
%matlabFunction(dx_subs,'Vars',{t, z, theta1, theta2, dz, dtheta1, dtheta2});
%微分方程式を解く
tspan=[0 5];
q0 = [0 0 0]';
dq0 = [0 0 0]';
dy0 = [q0; dq0];
[t, x_ans] = ode45(@dx_function, tspan, [0 0 0 0 0 0]);
%ode45(dx_MF, tspan, dy0);
Answers (0)
Categories
Find more on 数値積分と微分方程式 in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!