Re: URGENT!! Referencing a matrix from another vector
- From: "Sushma Sharma" <ssharmanospam@xxxxxxxxx>
- Date: Sat, 29 Apr 2006 21:39:28 -0400
one way would be to create a logical matrix, t= a==1. Then use repmat
to creat t2 = [t t]. Multiply t2 with b, i.e. c = t2.*b. Now you can
remove the rows with zeros, c(all(c,2)==0,:)=[]
While not elegant, I think it will do the job. (i'd love to know any
better ways there are)
sushma
charles benzinger wrote:
.
Hi,
This is a follow up to a question I posted earlier:
Suppose I have a 9x1 matrix a = [ 1 2 2 4 2 1 1 5 1]'. Let b=
rand(9,2).
I want to create matrix c (n x 2) matrix, where the first column in
c
are the elements in teh first column of b where a==1. I want the
second column to be elements in teh second column of b where a==1.
I have tried c = b(a==1), but that returns one column of outpur (it
stacks the two columns I want into one).
Any help would be appreciated!!!
cb
- References:
- URGENT!! Referencing a matrix from another vector
- From: charles benzinger
- URGENT!! Referencing a matrix from another vector
- Prev by Date: Re: Smooth interpolation for sparce data set from a gridded data set
- Next by Date: Re: surface plot
- Previous by thread: URGENT!! Referencing a matrix from another vector
- Next by thread: Re: URGENT!! Referencing a matrix from another vector
- Index(es):
Relevant Pages
|