Error: invalid call problem

조회 수: 14 (최근 30일)
Fitri Z
Fitri Z 2022년 1월 10일
댓글: Walter Roberson 2022년 1월 10일
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

답변 (1개)

Walter Roberson
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
Torsten
Torsten 2022년 1월 10일
편집: Torsten 2022년 1월 10일
Usually explicitly defining "angle" as a variable somewhere should hinder conflicts with the internal function "angle". But renaming the variable "angle" maybe solves your problem.
Walter Roberson
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 CenterFile Exchange에서 Octave에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by