Not enough input arguments ode45
Trying to find theta, angular velocity, and angular acceleration.
clear all
close all
clc
syms theta1(t)
%physical constants
Dd=0.1; Dw=0.75; Dh=0.5; Dm=15; ax=0.1; ay=0.5; b=0.25;
a = sqrt(ax^2 + ay^2); Jd = (1/3)*Dm*Dh^2;
Dweight=Dm*9.81;
thetaD0 = 0;
dthetaDdt0=0;
PHI = atand(ax/ay);
Lo = sqrt(a^2 + b^2 -2*a*b*cosd(PHI));
xmax = sqrt(a^2 + b^2 -2*a*b*cosd(PHI+90)) – Lo;
Ltotal = Lo + xmax;
k=500;
numphi = a*sind(PHI + thetaD0);
denphi = sqrt(a^2 + b^2 -2*a*b*cosd(PHI+thetaD0));
phi = asind(numphi/denphi);
d = 0.01;
%motor
NoLoadSpeed = 1057.672; %rad/s
Kt = 0.01386; %Vsec/rad
NoLoadI = 0.036; %A
Cvf = Kt*NoLoadI/NoLoadSpeed;
Jm =4.2E-7; %kg m^2
w = 1.5708/4 ; %rad/s
x = sqrt(a^2 + b^2 -2*a*b*cosd(PHI+theta1)) – Lo;
i=0.036;
[t, sol] = calcsum(thetaD0, dthetaDdt0, Cvf, b, phi, d, Dh, Dm, k, i, Kt, x, Jd, Jm)
%sol = [0;0;0]
%derivs = myODE(t, sol, Cvf, b, phi, d, Dh, Dm, k, i, Kt, x, thetaD0, Jd, Jm)
%%
function [t, sol] = calcsum(thetaD0, dthetaDdt0, Cvf, b, phi, d, Dh, Dm, k, i, Kt, x, Jd, Jm)
sol0 = [thetaD0; dthetaDdt0; i];
tspan = [0, 5];
[t, sol] = ode45(@(t, sol) myODE(sol, Cvf, b, phi, d, Dh, Dm, k, i, Kt, x, thetaD0, Jd, Jm), tspan, sol0);
end
%%
function derivs = myODE(t, sol, Cvf, b, phi, d, Dh, Dm, k, i, Kt, x, thetaD, Jd, Jm) %calc
dthetaDdt = sol(1);
g = (Kt*i – Cvf*dthetaDdt*(2*pi*b*sind(phi)/d));
num = 2*((2*pi/d)*((Kt*i – Cvf*dthetaDdt*(2*pi*b*sind(phi)/d))) + k*x)*b*sind(phi) – 0.5*Dm*9.81*Dh*sin(thetaD);
h = pi*b*sin(phi)/d;
den = Jd + 8*Jm*h^2;
ddthetaDdt = num/den;
derivs = [dthetaDdt; ddthetaDdt];
endTrying to find theta, angular velocity, and angular acceleration.
clear all
close all
clc
syms theta1(t)
%physical constants
Dd=0.1; Dw=0.75; Dh=0.5; Dm=15; ax=0.1; ay=0.5; b=0.25;
a = sqrt(ax^2 + ay^2); Jd = (1/3)*Dm*Dh^2;
Dweight=Dm*9.81;
thetaD0 = 0;
dthetaDdt0=0;
PHI = atand(ax/ay);
Lo = sqrt(a^2 + b^2 -2*a*b*cosd(PHI));
xmax = sqrt(a^2 + b^2 -2*a*b*cosd(PHI+90)) – Lo;
Ltotal = Lo + xmax;
k=500;
numphi = a*sind(PHI + thetaD0);
denphi = sqrt(a^2 + b^2 -2*a*b*cosd(PHI+thetaD0));
phi = asind(numphi/denphi);
d = 0.01;
%motor
NoLoadSpeed = 1057.672; %rad/s
Kt = 0.01386; %Vsec/rad
NoLoadI = 0.036; %A
Cvf = Kt*NoLoadI/NoLoadSpeed;
Jm =4.2E-7; %kg m^2
w = 1.5708/4 ; %rad/s
x = sqrt(a^2 + b^2 -2*a*b*cosd(PHI+theta1)) – Lo;
i=0.036;
[t, sol] = calcsum(thetaD0, dthetaDdt0, Cvf, b, phi, d, Dh, Dm, k, i, Kt, x, Jd, Jm)
%sol = [0;0;0]
%derivs = myODE(t, sol, Cvf, b, phi, d, Dh, Dm, k, i, Kt, x, thetaD0, Jd, Jm)
%%
function [t, sol] = calcsum(thetaD0, dthetaDdt0, Cvf, b, phi, d, Dh, Dm, k, i, Kt, x, Jd, Jm)
sol0 = [thetaD0; dthetaDdt0; i];
tspan = [0, 5];
[t, sol] = ode45(@(t, sol) myODE(sol, Cvf, b, phi, d, Dh, Dm, k, i, Kt, x, thetaD0, Jd, Jm), tspan, sol0);
end
%%
function derivs = myODE(t, sol, Cvf, b, phi, d, Dh, Dm, k, i, Kt, x, thetaD, Jd, Jm) %calc
dthetaDdt = sol(1);
g = (Kt*i – Cvf*dthetaDdt*(2*pi*b*sind(phi)/d));
num = 2*((2*pi/d)*((Kt*i – Cvf*dthetaDdt*(2*pi*b*sind(phi)/d))) + k*x)*b*sind(phi) – 0.5*Dm*9.81*Dh*sin(thetaD);
h = pi*b*sin(phi)/d;
den = Jd + 8*Jm*h^2;
ddthetaDdt = num/den;
derivs = [dthetaDdt; ddthetaDdt];
end Trying to find theta, angular velocity, and angular acceleration.
clear all
close all
clc
syms theta1(t)
%physical constants
Dd=0.1; Dw=0.75; Dh=0.5; Dm=15; ax=0.1; ay=0.5; b=0.25;
a = sqrt(ax^2 + ay^2); Jd = (1/3)*Dm*Dh^2;
Dweight=Dm*9.81;
thetaD0 = 0;
dthetaDdt0=0;
PHI = atand(ax/ay);
Lo = sqrt(a^2 + b^2 -2*a*b*cosd(PHI));
xmax = sqrt(a^2 + b^2 -2*a*b*cosd(PHI+90)) – Lo;
Ltotal = Lo + xmax;
k=500;
numphi = a*sind(PHI + thetaD0);
denphi = sqrt(a^2 + b^2 -2*a*b*cosd(PHI+thetaD0));
phi = asind(numphi/denphi);
d = 0.01;
%motor
NoLoadSpeed = 1057.672; %rad/s
Kt = 0.01386; %Vsec/rad
NoLoadI = 0.036; %A
Cvf = Kt*NoLoadI/NoLoadSpeed;
Jm =4.2E-7; %kg m^2
w = 1.5708/4 ; %rad/s
x = sqrt(a^2 + b^2 -2*a*b*cosd(PHI+theta1)) – Lo;
i=0.036;
[t, sol] = calcsum(thetaD0, dthetaDdt0, Cvf, b, phi, d, Dh, Dm, k, i, Kt, x, Jd, Jm)
%sol = [0;0;0]
%derivs = myODE(t, sol, Cvf, b, phi, d, Dh, Dm, k, i, Kt, x, thetaD0, Jd, Jm)
%%
function [t, sol] = calcsum(thetaD0, dthetaDdt0, Cvf, b, phi, d, Dh, Dm, k, i, Kt, x, Jd, Jm)
sol0 = [thetaD0; dthetaDdt0; i];
tspan = [0, 5];
[t, sol] = ode45(@(t, sol) myODE(sol, Cvf, b, phi, d, Dh, Dm, k, i, Kt, x, thetaD0, Jd, Jm), tspan, sol0);
end
%%
function derivs = myODE(t, sol, Cvf, b, phi, d, Dh, Dm, k, i, Kt, x, thetaD, Jd, Jm) %calc
dthetaDdt = sol(1);
g = (Kt*i – Cvf*dthetaDdt*(2*pi*b*sind(phi)/d));
num = 2*((2*pi/d)*((Kt*i – Cvf*dthetaDdt*(2*pi*b*sind(phi)/d))) + k*x)*b*sind(phi) – 0.5*Dm*9.81*Dh*sin(thetaD);
h = pi*b*sin(phi)/d;
den = Jd + 8*Jm*h^2;
ddthetaDdt = num/den;
derivs = [dthetaDdt; ddthetaDdt];
end ode45 MATLAB Answers — New Questions