"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 件のコメント
採用された回答
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 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!