Empty matrices
LUK ShunTim
shuntim.luk at polyu.edu.hk
Wed Oct 15 01:24:17 CDT 2008
Hi,
This snippet is taken from some matlab code:
fd=inline('sqrt(sum(p.^2,2))-1','p');
p=[0.01 0.00; -0.51 -0.05; 0.01 -0.20] % NG!
%p=[1.01 0.00; -0.51 -0.05; 0.01 -0.20] % Works
%p=[1.01 0.00; -1.51 -0.05; 0.01 -1.20] % Works
d=feval(fd, p)
ix=d>0
a=d(ix)
val=0.05;
b=feval(fd, [p(ix,1)+val, p(ix,2)])
res=b-a
It works when ix returns at less one non-zero index but fails if ix=0.
The result of using p=[0.01 0.00; -0.51 -0.05; 0.01 -0.20] is:
ix =
0
0
0
a = [](0x0)
b = [](0x1)
error: operator -: nonconformant arguments (op1 is 0x1, op2 is 0x0)
error: evaluating binary operator `-' near line 14, column 6
I cannot claim that the matlab code works as I've no matlab installed to
do the test, though. :-(
How to proceed? Or is this a bug in octave?
Thanks in advance,
ST
--
More information about the Help-octave
mailing list