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

1 次查看(过去 30 天)
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 个评论
Braden Kerr
Braden Kerr 2020-3-5
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))

请先登录,再进行评论。

采纳的回答

Walter Roberson
Walter Roberson 2020-3-5
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 个评论
Braden Kerr
Braden Kerr 2020-3-5
Agreed, the unfortunate circumstance of this assignment for homework dictates certain variable names for us.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

产品


版本

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by