You may want to start Octave with the option --traditional, which sets a number flags so that the interpreter handles things in a more compatible way. See the "porting" section of the octave FAQ: http://www.octave.org/FAQ.html#SEC24
Be sure you have a recent development version of octave and install octave-forge.
dbstop if error | -> | debug_on_error = 1 |
dbstop in mfile at lineno | -> | dbstop (func, line) |
dbclear in mfile at lineno | -> | dbclear (func, line) |
dbquit | -> | quit |
dbstack | -> | dbwhere |
dbcont | -> | dbg_cont |
dbstep in | -> | dbg_step |
dbstep | -> | dbg_next |
dbstatus | -> | dbstatus |
eval(['global ', n, '; ', n, '=V;']);
Be sure that in the top level context you do:
eval(['global ', n, ';']);
There is no way to write assignin('caller',...) without modifying the octave
interpreter. To get the effect of assignin('caller',...), you could write
your function so that it returns a structure and expand the structure using:
Or you could write my_fun as a script (not a function!!) which expects its
"parameters" to be in particular variables before it is invoked. You have
to be a lot more careful with your variables in the my_fun script, though,
since they might collide with those in the "caller".
for [key,val] = my_fun(...)
eval([key "=val;"]);
end
And again, you could use global variables much like you would for the global context.
John Eaton (jwe@bevo.che.wisc.edu) says:
Actually, there is some code in the development sources (in the files liboctave/ArrayN.{h,cc}, liboctave/ArrayN-idx.h, and src/ov-re-nd-array.{h,cc}) that are a start, but they need to be finished, and then lots of other code will need to be changed to make use of the new N-d array data type(s).
You could use a list of matrices if you just want to organize your arrays, but not slice them arbitrarily.
You could define and indexing function on a very long vector as suggested in http://www.octave.org/octave-lists/archive/help-octave.2001/msg01170.html
If you want a general 3D matrix you could arrange your matrix as:
and use the following indexing functions:
M.xn = rows
M.yn = columns
M.zn = number of slices
M.data = [ M1; M2; ...; Mzn ];
It would be nice to have a functions for setting elements and
slices as well.
function y = elem(A,i,j,k)
y = A.data(i + A.xn*(k-1), j);
endfunction
function M = slice(A,xidx,yidx,zidx)
if length(zidx) == 1
M = A.data ( xidx+(zidx-1)*A.xn, yidx );
elseif length(yidx) == 1
# XXX FIXME XXX maybe can do this in one step ?
M = reshape ( A.data ( : , yidx ), A.xn, A.zn);
M = M(xidx,zidx);
elseif length(xidx) == 1
M = A.data ( xidx+[zidx-1]*A.xn, yidx );
else
error("subvolumes not yet supported");
end
endfunction