Error: invalid call problem

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

Answers (1)

Walter Roberson
Walter Roberson on 10 Jan 2022
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 Comments

Yes I'm using Octave indeed because it's a free version, btw thanks for the clarification
Torsten
Torsten on 10 Jan 2022
Edited: Torsten on 10 Jan 2022
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.
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.

Sign in to comment.

Products

Asked:

on 10 Jan 2022

Commented:

on 10 Jan 2022

Community Treasure Hunt

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

Start Hunting!