> I am using the symbolic package, I have installed `2.5.0` from the source
> . I get this error in Octave 4.3.0+
> syms x;
> f(x) = nan
> error: subscript indices must be integers or boolean
> error: called from
> subsindex at line 64 column 5
> I am a bit confused. Is this expected?
> But if I do
> syms x;
> f(x) = nan + x
> f(x) = (symfun) nan
> Maybe Octave cannot identify `f(x) = nan` to be a symfun. But it gets to
> know that when we do `f(x) = nan + x` because x is a symbol.
> Is it a bug, or is it expected?
Whether or not it's expected, this is 'compatible' behavior. In Matlab 2016b:
>> syms x
>> f(x) = nan
Error using sym/subsindex (line 769)
Invalid indexing or function definition. When defining a function,
ensure that the arguments are symbolic variables and the body of the
function is a SYM expression. When indexing, the input must be
numeric, logical, or ':'.
Re: Octave Symbolic package: assign `nan` to symfun
On 06/02/17 07:17, Nicholas Jankowski wrote:
> On Mon, Feb 6, 2017 at 8:59 AM, NVS Abhilash <[hidden email]> wrote:
>> I am using the symbolic package, I have installed `2.5.0` from the source
>> . I get this error in Octave 4.3.0+
>> Is it a bug, or is it expected?
> Whether or not it's expected, this is 'compatible' behavior. In Matlab 2016b:
I think its a least somewhat expected. The same "problem" can be seen
without the nan:
clear f % (different behavior if f already exists)
f(x) = 7
The way to do this sort of thing is:
f(x) = sym(7)
f(x) = sym(nan)
I think there is not much we can do because Octave (and Matlab I expect)
do not call `@sym/subsasgn` in this case. We could document it as a
"gotcha" in "help symfun": pull request welcome.
Actually, perhaps `@sym/subindex` could detect when its passed a Symbol
and say something like:
error ('are you perhaps trying to make a symfun from a non-sym rhs
object? If so, try using "f(x) = sym(<rhs>)"')