Not Enough Input Arguments ode15s

24 Ansichten (letzte 30 Tage)
Neil Solan
Neil Solan am 7 Feb. 2018
Beantwortet: JK am 7 Feb. 2018
Trying to solve an ODE using ode15s and I'm getting this error:
Not enough input arguments.
Error in Homework3>ode1 (line 153)
theta_double_dot =
(F_0/J_eff)*cos(omega*t1)-(C_eff/J_eff)*(thetadot)-(K_eff/J_eff)*theta;
Error in Homework3 (line 113)
[t1,Y1] = ode15s(ode1,tspan,Initial,options);
Here is my code:
Initial = [theta_0,theta_dot_0,I_0];
tspan = 0:0.1:10;
%Linear Equation Solution:
[t1,Y1] = ode15s(ode1,tspan,Initial,options);
theta = Y1(:,1);
thetadot = Y1(:,2);
I = Y1(:,3);
function dxdt = ode1(t1,Y1)
g = 9.81; %[m/s^2]
M_b = 1; %[kg]
M = 0.5; %[kg]
m = 3; %[kg]
J_b = 1.25; %[kg/m^2]
k_1 = 250; %[N/m]
c_1 = 5; %[N*s/m]
c_2 = 10; %[N*s/m]
L = 1.1; %[m]
s = 0.4; %[m]
h = 0.8; %[m]
L_induct = 400*10^-6; %[H]
R = 100; %[Ohms]
alpha = 0.4; %[V*s/m]
a = 0.45; %[m]
b = 0.6; %[m]
F_0 = 15; %[N]
omega = 4.3508; %[rad/s]
theta_0 = -pi/8; %[rad]
theta_dot_0 = 0.1; %[rad/s]
I_0 = 0; %[A]
J_eff = J_b+M*(L-s)^2+((m/L)*((L-s)^3+s^3)/3);
K_eff = ((k_1*(h-s)^2)+(M_b*g*s)-(M*g*(L-s))-(m*g*((L/2)-s)));
C_eff = ((c_1*(h-s)^2)+(c_2*(s)^2));
Initial = [theta_0,theta_dot_0,I_0];
theta = Initial(1);
thetadot = Initial(2);
I = Initial(3);
theta_double_dot = (F_0/J_eff)*cos(omega*t1)-(C_eff/J_eff)*(thetadot)-(K_eff/J_eff)*theta;
I_eq = (alpha*(sqrt(((L-s)*cos(theta*thetadot-a))^2+((L-s)*sin(theta*thetadot-b))^2)-(I*R))/L_induct);
dxdt = zeros(size(Initial));
dxdt(1) = thetadot;
dxdt(2) = theta_double_dot;
dxdt(3) = I_eq;
end
I really don't have much experience with ode15s at all so for all I know I could be completely off with this one, so any other mistakes that you might see and could point out would be greatly appreciated. Thanks!

Antworten (1)

JK
JK am 7 Feb. 2018
Here is the code: please ask if you have any further queries.
theta_0=1; % put your values here
theta_dot_0=2; % put your values here
I_0=3; % put your values here
Initial = [theta_0,theta_dot_0,I_0]';
tspan = 0:0.1:10;
%Linear Equation Solution:
[t1,Y1] = ode15s(@(t,Y) ode1(t,Y),tspan,Initial);
theta = Y1(:,1);
thetadot = Y1(:,2);
I = Y1(:,3);
figure
plot(t1,Y1(:,1));
title('theta');
figure
plot(t1,Y1(:,2));
title('thetadot');
figure
plot(t1,Y1(:,3));
title('I');
function dxdt = ode1(t1,~)
g = 9.81; %[m/s^2]
M_b = 1; %[kg]
M = 0.5; %[kg]
m = 3; %[kg]
J_b = 1.25; %[kg/m^2]
k_1 = 250; %[N/m]
c_1 = 5; %[N*s/m]
c_2 = 10; %[N*s/m]
L = 1.1; %[m]
s = 0.4; %[m]
h = 0.8; %[m]
L_induct = 400*10^-6; %[H]
R = 100; %[Ohms]
alpha = 0.4; %[V*s/m]
a = 0.45; %[m]
b = 0.6; %[m]
F_0 = 15; %[N]
omega = 4.3508; %[rad/s]
theta_0 = -pi/8; %[rad]
theta_dot_0 = 0.1; %[rad/s]
I_0 = 0; %[A]
J_eff = J_b+M*(L-s)^2+((m/L)*((L-s)^3+s^3)/3);
K_eff = ((k_1*(h-s)^2)+(M_b*g*s)-(M*g*(L-s))-(m*g*((L/2)-s)));
C_eff = ((c_1*(h-s)^2)+(c_2*(s)^2));
Initial = [theta_0,theta_dot_0,I_0];
theta = Initial(1);
thetadot = Initial(2);
I = Initial(3);
theta_double_dot = (F_0/J_eff)*cos(omega*t1)-(C_eff/J_eff)*(thetadot)-(K_eff/J_eff)*theta;
I_eq = (alpha*(sqrt(((L-s)*cos(theta*thetadot-a))^2+((L-s)*sin(theta*thetadot-b))^2)-(I*R))/L_induct);
dxdt = zeros(3,1);
dxdt(1) = thetadot;
dxdt(2) = theta_double_dot;
dxdt(3) = I_eq;
end

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by