Error "Not enough input arguments" for half- model vehicle pitch angle

2 views (last 30 days)
My simulation was working fine a few weeks ago now I get this error code:
Not enough input arguments.
Error in pitch (line 85)
validateRequiredInputs(x,fs)
Error in matlabsimat78 (line 71)
plot3 = plot(tout,pitch);
Below is my M-file:
%% Define parameters
v= 30/3.6; % vehicle speed [m/s]
a= 1.18; % lengtth from front axle to cog [m]
b= 1.42; % length from rear axle to cog [m]
l= a+b; % wheelbase [m]
I_yy= 4000;% inertia yy (SI) of vehicle [kgm^2]
k_f= 2400; % spring stiffness front [N/m]
k_r= 1700; % spring stiffness rear [N/m]
C_f= 2100; % damping stiffness front [Ns/m]
C_r= 2500; % damping stiffness rear [Ns/m]
m_tot= 1500; % total mass [kg]
Z_i= 0.1; % vertical displacement [m]
t_delay= l/v; % time delay between front and rear axle
%% Calculations of mass distribution
m_f= I_yy/(a*(a+b)); % effective mass front [kg]
m_r= I_yy/(b*(a+b)); % effective mass rear [kg]
m_c= m_tot - (I_yy/(a*b)); % coupling mass [kg]
%% Signal Builder and plotting the graphs in matlab
% For creating the vertial displacement "z=0.1" imitating the bump on the road,
% Take into consideration the time delay between front and rear
% tires.
disp('Script to illustrate the graphs')
% Defining four set points in the signal builder
% 1st point
t1=0;
y1=0;
% 2nd point
t2=1/v;
y2=0;
% 3rd point
t3=2/v;
y3=0.1;
% 4th point
t4=3/v;
y4=0.1;
% 5th point
t5=4/v;
y5=0;
% 6th point
t6=5/v;
y6=0;
% defining the points in an array
t=[t1 t2 t3 t4 t5 t6];
y=[y1 y2 y3 y4 y5 y6];
% defining the array in the signal builder where z_i is the signal input of the model
signalbuilder('stint_vehicle_model/Speed bumper','set','speed_bumper','Group 1', t, y)
% Simulating the simulink model
sim('stint_vehicle_model')
% Graph:1 displacement vs road input vs time
subplot(3,1,1)
plot1= plot(tout,displacement_front,'blue',tout,displacement_rear,'red',tout,speed_bumper,'green');
legend(' Front suspension displacement','Rear suspension displacement','Vertical displacement')
grid on
xlabel('Time [s]')
ylabel('Displacement [m]')
title 'Displacement of vehicle Suspension system'
% Graph 2: pitch vs time
subplot (3,1,2)
plot3 = plot(tout,pitch);
legend('Pitch')
grid on
xlabel('Time [s]')
ylabel('Pitch [radians]')
title 'Pitch Angle of the vehicle'
% Graph 3: Suspension forces vs time
subplot (3,1,3)
plot2 = plot(tout,damping_force_front,tout,damping_force_rear);
legend('Front suspension force','Rear suspension force')
grid on
xlabel('Time [s]')
ylabel('Force [N]')
title 'Suspension forces in the vehicle system'
I do not know what I am doing wrong. Can some please help me out. thanks in advance.
  2 Comments
Walter Roberson
Walter Roberson on 21 Mar 2021
Are you expecting that when you sim() the model, that your model has a Save To Workspace that saves a variable named pitch ? Along with tout and displacement_front and displacement_rear and speed_bumper and damping_force_front and damping_force_rear ?
The sim() call appears to be leaving some of those in your workspace, but it is not creating pitch
sadat golz
sadat golz on 21 Mar 2021
Yes those are the outputs I am looking for. All appear in the workspace, but I do not understand why it doesnt show me the pitch angle graph. the other two graphs are just fine, only the pitch doesnt seem to work.

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 21 Mar 2021
Assign something (anything) to the variables
damping_force_front damping_force_rear displacement_front displacement_rear pitch speed_bumper tout
before you call sim()
In current versions of MATLAB, if there is a name that is not obviously in scope (assigned to, or a parameter, or a global or persistent, or a shared variable), then if there is a function of that name, MATLAB is entitled to expect that the name refers to the function and that the name will not be "poofed into existence" by an assignin() or sim() or by running a script.

Categories

Find more on Vehicle Scenarios 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!