Error: invalid call problem
9 次查看(过去 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!