Error: invalid call problem
조회 수: 14 (최근 30일)
이전 댓글 표시
I'm creating a pre function and an error occured, here is my script:
%func to calc tmax of a projectile motion
function[tmax]=Time_of_Flight(U,angle);
[converted_trig]=rad_angle(angle)
tmax=2.*U.*converted_trig./9.81;
%func to convert radian to degree
function[converted_trig]=rad_angle(angle)
converted_trig =sin((angle.*pi./180));
When I'm run the source code, I get error:
>> Time_of_Flight
error: Invalid call to angle. Correct usage is:
-- angle (Z)
error: called from
print_usage at line 98 column 5
Time_of_Flight at line 4 column 17
댓글 수: 0
답변 (1개)
Walter Roberson
2022년 1월 10일
In order to explain that, we will need to know which MATLAB release you are using.
I have not seen those messages in a long time, and I would have to go back and test to see exactly what is going on.
Indeed, my memory must be failing me at the moment, as I would really have though that those were messages from Octave rather than from MATLAB. Octave is a different programming language that is not compatible with MATLAB in this matter, so if you are using Octave you would need to inquire at an Octave help forum.
댓글 수: 3
Walter Roberson
2022년 1월 10일
If you were using MATLAB then you would have received a quite different message indicating that you had not provided enough input arguments. In MATLAB if you define a parameter then inside the function, references to that name will give you a "not enough parameter" message unless you pass in enough parameters.
To put it another way: you are running the function without supplying parameters, but you are expecting that the program will be able to find values for those parameters somewhere. MATLAB has a well-defined result in such cases. Octave... I have no idea what its search rules are.
Reminder: the purpose of Octave is to bankrupt Mathworks, so if you want help with Octave you have come to the wrong place.
참고 항목
카테고리
Help Center 및 File Exchange에서 Octave에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!