help-octave
[Top][All Lists]
Advanced

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

RE: bug compatibility ;-)


From: Ted Harding
Subject: RE: bug compatibility ;-)
Date: Tue, 23 Mar 1999 10:46:00 -0000 (GMT)

On 23-Mar-99 Daniel Heiserer wrote:
> Hi,
> 
> The thing is that I want to filter some data in a matrix using find
> and reassign new values than. Unfortunately I don't know how to do 
> that in octave.
> 
> example:
> a=rand(4,4);
> b=find(a<0.3);
> c=find(a>0.7);
> a(b)=0;
> a(c)=1;

A work-around which I have been using even in old versions of octave
involves a line like

  a(a<0.3) = S(a<0.3);

where "S" is a matrix of substitute values of the same size as "a".

E.g.

  U = ones(size(a)); N = zeros(size(a));
  a=rand(4,4);
%%  b=find(a<0.3);
%%  c=find(a>0.7);
%%  a(b)=0;
%%  a(c)=1;
  a(a<0.3) = N(a<0.3);
  a(a>0.7) = U(a>0.7);

Apparently this also works in MatLab in the same way.

Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <address@hidden>
Date: 23-Mar-99                                       Time: 10:46:00
------------------------------ XFMail ------------------------------



reply via email to

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