Not enough input arguments.
Afficher commentaires plus anciens
Heya guys,
Im not quite sure if i need add anonymous function or if there's something else:
Not enough input arguments.
Error in Motorcycle>s (line 49)
x=q(1,1);
Error in Motorcycle (line 38)
q = ode(q0,t0,t,s) ;
% Initial Commands
clc;
clear;
close all force
diary('off')
fclose('all') ;
% Simulation physics
x0= 0; %Initial position [s]
v0= 0.1; %Initial velocity [m/s]
t0= 0; %Final time [s]
tf=100; % [s]
dt= 0.1; % Time increment [s]
% Physical parameters
global par;
par.p_max= 22080; % maximum power [W]
par.r= 70; % Rider Mass [Kg]
par.bike= 145.4; % Motorcycle Mass [Kg]
par.m_c= par.r + par.bike; % Total Mass [Kg]
par.k_a= 0.65; % Aerodynamic drag factor [kg/m]
par.c_r= 0.02; % Roll resistance factor
par.mu = 1.1; % Friction Coefficient
par.w= -0; % Wing speed [m/s]
pi= 3.141592; %pi
par.teta= 0/180*pi; % Lane slope angle [rad]
par.g=9.81; % Gravity Acc. [m/s^2]
par.p_d= 1.345; % Wheelbase [m]
par.p_cg= 0.63; % Cog from rear wheel With rider h [m]
par.h_cg= 0.58; % CoG height h with rider h [m]
par.h_cp=0.78; % Pressure CoG height
% Vectors
q0= [x0;v0];
t =t0:dt:tf;
% Solution
q = ode(q0,t0,t,s) ;
x=q(1,:);
v=q(2,:);
%Graphs
plot(t,v*3.6,'k-')
xlabel('$t\quad[s]$','fontsize',4);
ylabel('$v\quad[km/h]$','fontsize',4);
function f=s(t,q)
x=q(1,1);
v=q(2,1);
%Rider
alpha=1; % BRAAAAAAAAAAP Acc
beta_t= 0; % Rear Brake
beta_d=0; % Front Brake
% Engine
p_max= par.p_max; % Max. power cte
%Track
teta=par.teta; %Angle
mu=par.mu; %Friction Coefficient
W=par.w; %Wing speed [m/s]
%Forces
f_grx=-par.m_c*par.g*sin(teta); % x gravity component
f_gry= -par.m_c*par.g*cos(teta); % y gravity component
f_pro= alpha*p_max/v; %
f_aer=-par.k_a*(v-w)^2; % Drag
f_rol= -par.c_r*abs(f_gry); % Roll resistance
% d function
d=(f_pro+f_aer+f_rol+f_grx+beta_t*mu*f_gry+(beta_d-beta_t)*mu/par.p_d*(-f_aero*par.h_cp + -f_grx*par.h_cg+f_gry*par.p_cg))/(par.m_c*(1-(beta_d-beta_t)*mu*par.g_cg/par.p_d));
f(1)=v;
f(2)=d;
end
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Programming dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!