"Not enough input arguments" Error while calling multiple functions within another

1 view (last 30 days)
Hello,
In my script I have a fucntion that relies on 5 other functions, each of the subfunctions relies on two inputs, a and b. When these subfucntions, A, B, C, D, E are called with values for a and b, they give a numerical output so I know the functions work. However, when used within my larger function I, I get an error that states not enough inut functions. I cant figure out why since I is just a function that relies on the five subfucntions, all of which work independently with the two inputs I have specificied.
Here is my code:
disp(A(4,2))
disp(B(4,2))
disp(C(1,4))
disp(D(4,2))
disp(E(4,2))
disp(I(4,2))
function x = dis(j)
rad_15 = degtorad(15);
rad_345 = degtorad(345);
rad_195 = degtorad(195);
rad_neg15 = degtorad(-15);
theta = [rad_15 rad_345 rad_195 rad_neg15];
S = .5*cos(rad_15);
y_value = tan(rad_15)*.5;
points = [0 0; 0.5 y_value; 1 0; .5 -y_value];
x = points(j, 1) + S*cos(theta(j));
end
function y = dis2(k)
rad_15 = degtorad(15);
rad_345 = degtorad(345);
rad_195 = degtorad(195);
rad_neg15 = degtorad(-15);
theta = [rad_15 rad_345 rad_195 rad_neg15];
S = .5*cos(rad_15);
y_value = tan(rad_15)*.5;
points = [0 0; 0.5 y_value; 1 0; .5 -y_value];
y = points(k, 1) + S*sin(theta(k));
end
function Alpha = A(a,b)
rad_15 = degtorad(15);
rad_345 = degtorad(345);
rad_195 = degtorad(195);
rad_neg15 = degtorad(-15);
theta = [rad_15 rad_345 rad_195 rad_neg15];
y_value = tan(rad_15)*.5;
points = [0 0; 0.5 y_value; 1 0; .5 -y_value];
Alpha = -(dis(a)-points(b, 1))*cos(theta(b))-(dis2(a)-points(b, 2))*sin(theta(b));
end
function Bravo = B(a,b)
rad_15 = degtorad(15);
y_value = tan(rad_15)*.5;
points = [0 0; 0.5 y_value; 1 0; .5 -y_value];
Bravo = (dis(a)-points(b, 1)).^2+(dis2(a)-points(b, 2)).^2;
end
function Charlie = C(a,b)
rad_15 = degtorad(15);
rad_345 = degtorad(345);
rad_195 = degtorad(195);
rad_neg15 = degtorad(-15);
theta = [rad_15 rad_345 rad_195 rad_neg15];
Charlie = sin(theta(a) - theta(b));
end
function Delta = D(a,b)
rad_15 = degtorad(15);
rad_345 = degtorad(345);
rad_195 = degtorad(195);
rad_neg15 = degtorad(-15);
theta = [rad_15 rad_345 rad_195 rad_neg15];
y_value = tan(rad_15)*.5;
points = [0 0; 0.5 y_value; 1 0; .5 -y_value];
Delta = (dis2(a)-points(b, 2))*cos(theta(a))-(dis(a)-points(b, 1))*sin(theta(a));
end
function Echo = E(a,b)
Echo = sqrt(B(a,b) - (A(a,b)).^2);
end
function Ick = I(a,b)
rad_15 = degtorad(15);
rad_345 = degtorad(345);
rad_195 = degtorad(195);
rad_neg15 = degtorad(-15);
theta = [rad_15 rad_345 rad_195 rad_neg15];
S = .5*cos(rad_15);
y_value = tan(rad_15)*.5;
points = [0 0; 0.5 y_value; 1 0; .5 -y_value];
function x = dis(j)
x = points(j, 1) + S*cos(theta(j));
end
function y = dis2(k)
y = points(k, 1) + S*sin(theta(k));
end
function Alpha = A(a,b)
Alpha = -(dis(a)-points(b, 1))*cos(theta(b))-(dis2(a)-points(b, 2))*sin(theta(b));
end
function Bravo = B(a,b)
Bravo = (dis(a)-points(b, 1)).^2+(dis2(a)-points(b, 2)).^2;
end
function Charlie = C(a,b)
Charlie = sin(theta(a) - theta(b));
end
function Delta = D(a,b)
Delta = (dis2(a)-points(b, 2))*cos(theta(a))-(dis(a)-points(b, 1))*sin(theta(a));
end
function Echo = E(a,b)
Echo = sqrt(B(a,b) - (A(a,b)).^2);
end
Ick = (C/2) * ln( (S.^2+2*S*A(a,b)+ B(a,b)) / (B(a,b)) )+((D(a,b)-A(a,b)*C(a,b))/(E(a,b)))*(arctan((S+A(a,b))/(E(a,b)))-arctan(A(a,b)/E(a,b)));
end
  3 Comments
Braden Kerr
Braden Kerr on 5 Mar 2020
Not enough input arguments.
Error in AeroHW4>C (line 73)
Charlie = sin(theta(a) - theta(b));
Error in AeroHW4>I (line 100)
Ick =
(C/2)*ln((S.^2+2*S*A(a,b)+B(a,b))/(B(a,b)))+((D(a,b)-A(a,b)*C(a,b))/(E(a,b)))*(arctan((S+A(a,b))/(E(a,b)))-arctan(A(a,b)/E(a,b)));
Error in AeroHW4 (line 20)
disp(I(4,2))

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 5 Mar 2020
Ick = (C/2) * ln( (S.^2+2*S*A(a,b)+ B(a,b)) / (B(a,b)) )+((D(a,b)-A(a,b)*C(a,b))/(E(a,b)))*(arctan((S+A(a,b))/(E(a,b)))-arctan(A(a,b)/E(a,b)));
That line starts by calling C with no input arguments and dividing the result by 2
  3 Comments
Braden Kerr
Braden Kerr on 5 Mar 2020
Agreed, the unfortunate circumstance of this assignment for homework dictates certain variable names for us.

Sign in to comment.

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Products


Release

R2016b

Community Treasure Hunt

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

Start Hunting!