[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: column elimination
From: |
Judd Storrs |
Subject: |
Re: column elimination |
Date: |
Mon, 19 Jul 2010 19:06:50 -0400 |
On Mon, Jul 19, 2010 at 6:48 PM, Victor Carreto Pavon
<address@hidden> wrote:
> 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?
I think you are asking for a generic way to eliminate columns using
only the column numbers you want to eliminate? I think the automatic
variable "end" and the setxor() function can get you that. So, for
example to remove columns 1 and 4 you could:
A = A(:,setxor(1:end,[1,4])) ;
and in the second case
A = A(:,setxor(1:end,[3,5])) ;
"end" is a special variable here that always equals the last index.
So, if A has 53 columns then 1:end is the same as 1:53--octave
automatically replaces end with the correct value so you don't need
the cols variable. setxor returns the numbers that are unique in the
two lists.
--judd
- name variable, insipido, 2010/07/16
- Re: name variable, bpabbott, 2010/07/16
- column elimination, insipido, 2010/07/19
- Re: column elimination, James Sherman Jr., 2010/07/19
- Re: column elimination, Victor Carreto Pavon, 2010/07/19
- Re: column elimination, James Sherman Jr., 2010/07/19
- Re: column elimination, Victor Carreto Pavon, 2010/07/19
- Re: column elimination, Ben Abbott, 2010/07/19
- Re: column elimination, Judd Storrs, 2010/07/19
- Re: column elimination, Victor Carreto Pavon, 2010/07/19
- Re: column elimination,
Judd Storrs <=
- Re: column elimination, Vic Norton, 2010/07/19