I am unsure how to fix "Not enough input arguments." problem

2 views (last 30 days)
I am unsure how to resolve two errors in my matlab program
1) "Not enough input arguments."
2) Error in test1 (line 30)
v = Chapra_Problem_1p7;
Any help would be appreciated.
  • * * * Here is my program: * * * *
% Input
% t: vector of time values [dt; t0; t1; tf]
% v0: initial velocity at time t=t0
% p: vector of parameters [m, c_d0, c_d1]
% g: Gravitational constant for right-hand-side gravity force
%
% Output
% v: velocity vector (downward speeds at each time)
%%Parse input variables
dt = t(1); % time increment, delta-t
t0 = t(2); % initial time
t1 = t(3); % time when parachute deploys
tf = t(4); % final time
m = p(1); % bungee jumper's mass
c_d0 = p(2); % drag coefficient for jumper alone
c_d1 = p(3); % drag coefficient for jumper with parachute
%%Insert your code here.
dvdt=0;
i=1;
time=t0 + dt;
while time<tf
if time<t1
dvdt = g-c_d0/m*v(i)^2;
v(i+1) = v(i) + dvdt*dt;
i = i + 1;
time = time + dt;
else
dvdt = g-c_d1/m*v(i)^2;
v(i+1) = v(i) + dvdt*dt;
i = i + 1;
time = time + dt;
end
end
end
%change c_d0 at t0 to c_d1 at t1, right now it is c_d
%c_d0 is drag before parachute, c_d1 is drag after parachute
* * * * * *Here is my test file for the program which has the variables: (nothing wrong here)* * * * * *
%%AOE 2074 Computer Lab Week 1 -- Cody Exercise
% Chapra Problem 1.7
% Numerical Solution to the Bungee Jumper Problem
% with non-zero initial condition and delayed parachute deployment
clear; clc
% Initialize time variables
dt = 1; % time increment
t0 = 0; % initial time
t1 = 10; % time when parachute deploys
tf = 20; % final time
t = [dt; t0; t1; tf];
% Initial condition
v0 = -20; % initial velocity (upward speed)
% Initialize parameters:
% m: bungee jumper's mass
% c_d0: drag coefficient for jumper alone
% c_d1: drag coefficient for jumper with parachute
m = 80.0; % kg
c_d0 = 0.25; % kg/m
c_d1 = 1.5; % kg/m
p = [m, c_d0, c_d1];
% g: Gravitational constant for right-hand-side gravity force
g = 9.81; % m/s^2
% Compute analytical solution for velocity (downward speed) at given values of time.
v = Chapra_Problem_1p7(t,v0,p,g);
Velocity = [
-20.0000
-8.9400
1.1198
10.9258
20.3628
28.8770
36.0812
41.8229
46.1668
49.3162
51.5260
11.5561
18.8622
22.0013
22.7352
22.8535
22.8707
22.8732
22.8735
22.8736
22.8736];
assert(norm(Velocity-v(:),inf)<1e-4)
2
%%Chapra Problem 1.7 for dt=1, tf=10 (before parachute opens)
v = Chapra_Problem_1p7( [1;0;10;10], -20, [80, 0.25, 1.5], 9.81 );
Velocity = [
-20.0000
-8.9400
1.1198
10.9258
20.3628
28.8770
36.0812
41.8229
46.1668
49.3162
51.5260];
assert(norm(Velocity-v(:),inf)<1e-4)
3
%%Chapra Example 1.2 for v0=0, dt=2, t1=12, tf=12 (no parachute)
v = Chapra_Problem_1p7( [2;0;12;12], 0, [68.1, 0.25, 0.25], 9.81 );
% Check error against textbook solution given in table on page 11.
Velocity = [0
19.6200
36.4137
46.2983
50.1802
51.3123
51.6008];
assert(norm(Velocity-v(:),inf)<1e-4)
4
%%Chapra Example 1.2 for v0=0, dt=1, t1=10, tf=12 (after parachute opens)
Velocity = [50.4287; 4.2243; 13.6412];
v = Chapra_Problem_1p7( [1;0;10;12], 0, [68.1, 0.25, 1.5], 9.81 );
v_10to12 = v(end-2:end);
assert(norm(Velocity-v_10to12(:),inf)<1e-4)
5
%%Chapra Section 1.4 Case Study for v0=-40, dt=2, t1=tf=4, m=68.1
v = Chapra_Problem_1p7( [2;0;4;4], -40, [68.1, 0.25, 0.25], 9.81 );
Velocity = [
-40.0000
-8.6326
11.5346];
assert(norm(Velocity-v(:),inf)<1e-4)
  1 Comment
Geoff Hayes
Geoff Hayes on 28 Aug 2014
Bradley - if you were to run the above code, formatted as it is, do you still observe the same error? I could not see any line of code that was just
v = Chapra_Problem_1p7;
It seems that, given all other calls to Chapra_Problem_1p7, this function must have four inputs so that could be the explanation for the error message. But since this line of code doesn't appear anywhere then maybe the problem has been resolved.
The
Error in test1 (line 30)
is a little puzzling too. Is test1 the name of this above function? And nowhere near line 30 does the Chapra_Problem_1p7 appear to be called.

Sign in to comment.

Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!