"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
Stephen23
Stephen23 2020년 3월 5일
Longer function names would help avoid that kind of bug.
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에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품


릴리스

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by