Reputation: 10329
I wrote the following function in a file named conditionals.m:
function result = conditionals(category, feature)
result=5;
end
I call this function from Octave's command line:
v=conditionals(3,4)
I get the following error:
error : A(I) : Index exceeds matrix dimension.
Whats wrong here?
Upvotes: 1
Views: 1818
Reputation: 1140
It happened to me as well and it can happen on any command, regardless of the command name. When I run the PS1(">>");
to change the command prompt in Ovtave, I got the same error.
octave-3.2.3.exe:9> PS1(">>");
error: A(I): Index exceeds matrix dimension.
As others also mentioned, this error fires when there is a parameter with the same command name. It happens when we mistakenly enter the command with wrong syntax and hence, octave run the command and produce a variable with your command name that overload the internal command.
You can verify this status by who
command. If you can see the same variable name as your command here, you have to remove it. Use clear variable_name
to remove the variable.
Here is my output for PS1 command.
Hope it helps.
Upvotes: 0
Reputation: 46365
The error:
error : A(I) : Index exceeds matrix dimension.
Indicates that octave thinks that conditionals
is a matrix, not a function.
Octave probably doesn't know that conditionals
is a function - and instead it's treating it as a matrix.
Have you checked to see if the function is in Octave's search path?
Upvotes: 4
Reputation: 13081
This works for me.
octave> function result = conditionals (category, feature)
> result = 5;
> endfunction
octave> v = conditionals (3, 4)
v = 5
The error suggests that you have a variable with the same name as the function. Type whos
at the Octave prompt to see a list of defined variables. If you see one named conditionals
, remove it with clear conditionals
Also, if conditionals is a conditionals.m
file, make sure it's on the function search path. Run path
at the Octave prompt to see the function search path. Run which conditionals
at the command prompt to see where the function is located.
Upvotes: 0