Error trying to use a function within a function?
Afficher commentaires plus anciens
Here's the script:
function [x, y] = XYFromAngles(alpha, beta, AB)
[~, b]=triangle(alpha, beta, AB);
x=b*cos(alpha);
y=b*sin(alpha);
disp('[x, y]=');
disp([x, y]);
end
And the scrip for the function triangle:
function [a,b]=triangle(alpha,beta,c)
alpha=alpha/180*pi;
beta=beta/180*pi;
gamma=pi-alpha-beta;
a=c/sin(gamma)*sin(alpha);
b=c/sin(gamma)*sin(beta);
end
Then it gives the error:
Not enough input arguments.
Error in XYFromAngles (line 2)
[~, b]=triangle(alpha, beta, AB);
I have entered all of the variables that I've defined but it doesn't compute it.
3 commentaires
When you are calling
[~, b]=triangle(alpha, beta, AB);
are alpha, beta and AB defined?
If I create those 2 functions and call triangle, I get some results:
>>XYFromAngles(1,2,3)
[x, y]=
1.0809 1.6834
ans =
1.0809
also, a question just for understanding are the functions XYFromAngles and triangle in separate files or in one file?
Susannah Gurtler
le 11 Sep 2018
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Time Series Events dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!