help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Empty matrices


From: LUK ShunTim
Subject: Empty matrices
Date: Wed, 15 Oct 2008 14:24:17 +0800
User-agent: Mozilla-Thunderbird 2.0.0.16 (X11/20080724)

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
--



reply via email to

[Prev in Thread] Current Thread [Next in Thread]