help-octave
[Top][All Lists]
Advanced

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

Re: column elimination


From: Victor Carreto Pavon
Subject: Re: column elimination
Date: Mon, 19 Jul 2010 20:44:51 -0300

thanks Ben... that is pretty much I am looking for, James and Judd also thank you.

you all rule :)

On 19/07/2010, at 07:57 p.m., Ben Abbott wrote:


On Jul 19, 2010, at 6:48 PM, Victor Carreto Pavon wrote:

On 19/07/2010, at 07:25 p.m., James Sherman Jr. wrote:

On Mon, Jul 19, 2010 at 6:09 PM, Victor Carreto Pavon <address@hidden > wrote: thanks for the comment I certanly did not knew that A(:,[1 4 6]) will return columns 1, 4 and 6... but let's say that what I am looking for are the remaining columns from the original matrix A there fore what I want are columns 2, 3, 5...

I don't think I'm getting exactly what you're looking for. Do you want all the columns except 1 and 4? This can be done a couple ways, the most straight forward probably being:
cols = size(A, 2);
A(:, [2, 3, 5:cols])

Is this what you are asking?

yes... that is right; I want all the columns except 1 and 4 in this case, but maybe in the next case I might not want all the columns except 3 and 5. then the notation A(:,[2,3,5:cols]) will no longer be useful.

Do you know can I make it generic so it will work for any combination?

and thanks for answering.

If you just want to eliminate columns then ...

A(:,[1,4]) = [];

... will eliminate columns 1 and 4.

octave:12> A = rand (6)
A =

  0.704284   0.635028   0.998254   0.200610   0.963574   0.578821
  0.943338   0.427950   0.145803   0.477948   0.025938   0.331903
  0.894940   0.140775   0.518609   0.038302   0.232539   0.379098
  0.353322   0.360688   0.432351   0.328230   0.998258   0.844157
  0.682254   0.851592   0.945387   0.380018   0.812283   0.725536
  0.473056   0.776754   0.800953   0.717851   0.163009   0.649179

octave:13> A(:,[1,4]) = []
A =

  0.635028   0.998254   0.963574   0.578821
  0.427950   0.145803   0.025938   0.331903
  0.140775   0.518609   0.232539   0.379098
  0.360688   0.432351   0.998258   0.844157
  0.851592   0.945387   0.812283   0.725536
  0.776754   0.800953   0.163009   0.649179

Ben




reply via email to

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