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

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 comentarios

@Braden Kerr: please show us the complete error message. This means all of the red text.
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))

Iniciar sesión para comentar.

 Respuesta aceptada

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 comentarios

Wow thank you ive read through the rest of the function so many times checking for errors in parentheses that I just missed that entirely.
Longer function names would help avoid that kind of bug.
Agreed, the unfortunate circumstance of this assignment for homework dictates certain variable names for us.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre 2-D and 3-D Plots en Centro de ayuda y File Exchange.

Productos

Versión

R2016b

Preguntada:

el 5 de Mzo. de 2020

Comentada:

el 5 de Mzo. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by