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

mbvoyager
mbvoyager 2018년 9월 11일
편집: mbvoyager 2018년 9월 11일
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?
I defined alpha, beta and AB outside of running the command which I suspect is what caused my error. Does it only work if you enter it into the
XYFromAngles(alpha, beta, AB)
And yes they are in separate files.
Stephen23
Stephen23 2018년 9월 11일
편집: Stephen23 2018년 9월 11일
"Does it only work if you enter it into the..."
Yes.

댓글을 달려면 로그인하십시오.

 채택된 답변

Stephen23
Stephen23 2018년 9월 11일
편집: Stephen23 2018년 9월 11일

1 개 추천

I don't get any error when I call your function:
>> XYFromAngles(1,1,1)
[x, y]=
0.27019 0.42080
ans = 0.27019
>>
I suspect that you are clicking on the big green "Run" button, without providing any input values to the function. Ignore that big green "Run" button, it does not help you.

댓글 수: 2

I had defined alpha, beta and AB by typing in the command window
alpha=...; beta=...; AB=...;
Is this way not correct?
Stephen23
Stephen23 2018년 9월 11일
편집: Stephen23 2018년 9월 11일
"Is this way not correct?"
Its fine as a start... but you still need to provide those variables as inputs to the function:
XYFromAngles(alpha,beta,AB)
You defined the function to have three inputs, so you need to call it with three inputs. Note that names of the input arguments are totally unrelated to what happens inside that function (in case you thought that these are connected somehow).

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터 및 File Exchange에서 Time Series Events에 대해 자세히 알아보기

제품

릴리스

R2017b

질문:

2018년 9월 11일

편집:

2018년 9월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by