Effacer les filtres
Effacer les filtres

Not enough input arguments.

2 vues (au cours des 30 derniers jours)
Vinicius Dreher
Vinicius Dreher le 18 Avr 2021
Commenté : Vinicius Dreher le 21 Avr 2021
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

Nagasai Bharat
Nagasai Bharat le 21 Avr 2021
Hi,
I have made some changes to the code to eliminate the errors you are getting. Do have a look
Also added some comments where the changes were made.
% 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];
% t1 =t0:dt:tf;
% Solution
[t,q] = ode45(@s,[t0,tf],q0) ; % Correct usage of ode function ,
x=q(:,1); % Change in dimensions
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);
global par; % Global keyword needed
%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] % 'w' insteal of 'W'
%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_aer*par.h_cp + -f_grx*par.h_cg+f_gry*par.p_cg))/(par.m_c*(1-(beta_d-beta_t)*mu*par.p_cg/par.p_d));
% Check function d for any mistakes in variable names
% f(1)=v;
% f(2)=d;
f = [v;d]; % f needs to be a column matrix
end
  1 commentaire
Vinicius Dreher
Vinicius Dreher le 21 Avr 2021
Good afternoon Bharat,
Thank you for been comprehensive and explained that to me!
As you can see, I’m a totally beginner and now I believe I can start developing more skills!
Cheers

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by