A software library originally written for MATLAB, comprising of MATLAB and C source files, is being ported to Octave. The C code uses the MATLAB MEX file interface. The library works without error on MATLAB, but not on Octave. The C source is closed and I don't have access to it, but someone kindly compiled it for me.
The following Octave code
Y=ones(size(X)) + X;
fails with the error
Subscript indices must be either positive integers or logicals.
X is a matrix returned by the MEX module.
I've already verified that ones and size are referring to the builtin functions and not overwritten by some local variables.
How can I fix this?
EDIT Breaking down into steps:
S=size(X);
O=ones(S);
X+O;
gives the above error on the last line, the addition. The whos command outputs this:
octave:13> whos O X
Variables in the current scope:
Attr Name Size Bytes Class
==== ==== ==== ===== =====
O 512x512 2097152 double
X 512x512 2097152 double
Total is 524288 elements using 4194304 bytes
s = size(X)work? If so, what iss? Doesones(s)work? - Warren WeckesserX? What doeswhos Xreturns? - carandraugsize(X)returns[512 512]. - marczellm