Prev: plot 3d from matrix2d
Next: wilmofloyd@gmail.com
From: michael on 15 Jul 2010 15:59 My problem is this: I have a large array (say 200 x 6). I would like to: 1. For all rows greater than x(insert #) in column 1, and all rows greater than y(#) in column 2, (of those which satisfy both conditions) 2. find the row that has the minimum value for column 3 (of all the rows that pass the prev criteria) 3. For the row selected, read information from columns 4 and 5
From: Sean on 15 Jul 2010 16:07 "michael " <mkinn1(a)comcast.net> wrote in message <i1npa8$ijg$1(a)fred.mathworks.com>... > My problem is this: > > I have a large array (say 200 x 6). I would like to: > > 1. For all rows greater than x(insert #) in column 1, and all rows greater than y(#) in column 2, > > (of those which satisfy both conditions) > > 2. find the row that has the minimum value for column 3 (of all the rows that pass the prev criteria) > > 3. For the row selected, read information from columns 4 and 5 %%% One way x = [1:10]'; y = randperm([10])'; z = rand(10,1); min(z(x(x>5)&y(y>5)))
From: Sean on 15 Jul 2010 16:13 "Sean " <sean.dewolski(a)nospamplease.umit.maine.edu> wrote in message > %%% One way > x = [1:10]'; > y = randperm([10])'; > z = rand(10,1); > > min(z(x(x>5)&y(y>5))) One small mistake here; should read: min(z((x>5)&(y>5)))
From: dpb on 15 Jul 2010 16:11 michael wrote: > My problem is this: > > I have a large array (say 200 x 6). I would like to: > > 1. For all rows greater than x(insert #) in column 1, and all rows > greater than y(#) in column 2, > > (of those which satisfy both conditions) > > 2. find the row that has the minimum value for column 3 (of all the rows > that pass the prev criteria) > > 3. For the row selected, read information from columns 4 and 5 200x6 is actually a quite small array, but... :) In steps, make as much more concise as you desire... S = A(A(:,1)>x & A(:,2)>y; :); [mins,idx] = min(S(:,3)); V = [S(idx,4) S(idx,5)]; Salt to suit... --
From: michael on 15 Jul 2010 16:52 Thanks for your responses, guys. I ended up using the one from dpb. Everything is working great. the one syntax error is is should be: S = A(A(:,1)>x & A(:,2)>y, :); | S = A(A(:,1)>x & A(:,2)>y; :); Thanks again!
|
Pages: 1 Prev: plot 3d from matrix2d Next: wilmofloyd@gmail.com |