help-octave
[Top][All Lists]
Advanced

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

Re: help


From: Henry F. Mollet
Subject: Re: help
Date: Wed, 21 Sep 2005 14:37:59 -0700
User-agent: Microsoft-Entourage/11.1.0.040913

Method is probably not new and deletes rows of a matrix according to given
condition (values larger than 3 in col 3 in the following example, second
example uses row 3 for which no elements are < 3).
Henry
octave:51> File1=[1 1 1;2 2 2;3 3 3;4 4 4;5 5 5]
File1 =

  1  1  1
  2  2  2
  3  3  3
  4  4  4
  5  5  5

octave:52> [x y]=find(File1(:,3)>3)
x =

  4
  5

y =

  1
  1

octave:53> File1(x,:)=[]
File1 =

  1  1  1
  2  2  2
  3  3  3

Whereas:
octave:54> File1=[1 1 1;2 2 2;3 3 3;4 4 4;5 5 5]
File1 =

  1  1  1
  2  2  2
  3  3  3
  4  4  4
  5  5  5

octave:55> [x y]=find(File1(3,:)>3)  % no values are > 3 in row 3
x = [](1x0)
y = [](1x0)
octave:56> File1(x,:)=[]
File1 =

  1  1  1
  2  2  2
  3  3  3
  4  4  4
  5  5  5




on 9/21/05 8:48 AM, Mike Miller at address@hidden wrote:

> On Wed, 21 Sep 2005, David Bateman wrote:
> 
>> shashi kumar wrote:
>> 
>>> I w'd like to delete some selected rows of a 3 column matrix, say,
>>> 10000*3, and i have tried as given below command and got like this
>>> message. so kindly tell me how to make empty to particular rows with
>>> all column.
>>> 
>>> octave:1> load File1
>>> octave:2> [x y]=find(File1(:,3)>-3000)
>>> octave:3> []=File1(x,:);
>>> 
>> 
>> Shouldn't that read "File1(x,:)=[];" ?
> 
> 
> Interesting.  This must be a fairly new Octave feature.  So if I
> understand the method, setting elements of a matrix to '[]' deletes those
> elements and changes the original matrix to a row vector.
> 
> In this example, wouldn't this do the same thing (if all elements were
> real, complex or integer)?:
> 
> File1 = File1(find(File1(:,3)<=-3000));
> 
> When there might be NaNs, the result could be different.
> 
> Mike
> 
> 
> 
> -------------------------------------------------------------
> Octave is freely available under the terms of the GNU GPL.
> 
> Octave's home on the web:  http://www.octave.org
> How to fund new projects:  http://www.octave.org/funding.html
> Subscription information:  http://www.octave.org/archive.html
> -------------------------------------------------------------
> 




-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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