Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.


Ian
Posts:
14
Registered:
9/21/10


Re: Quick Problem (sorting data)
Posted:
Sep 30, 2010 11:01 AM


"Jos (10584) " <#10584@fileexchange.com> wrote in message <i81ruo$9o3$1@fred.mathworks.com>... > "Ian " <ikirby23@yahoo.com> wrote in message <i81og5$1g7$1@fred.mathworks.com>... > > "Jos (10584) " <#10584@fileexchange.com> wrote in message <i81jtr$bm6$1@fred.mathworks.com>... > > > "Ian " <ikirby23@yahoo.com> wrote in message <i81j9m$27e$1@fred.mathworks.com>... > > > > In matlab how would I locate the values from (g) using the values from (f) and create them as a seperate variable (h): > > > > > > > > g=[ 7 2520 > > > > 8 2375 > > > > 10 3618 > > > > 12 2694 > > > > 14 2158 > > > > 15 2842] > > > > > > > > f=[2520;3618;2842] > > > > > > > > The variable I would want to create from (g) using (f) would be: > > > > > > > > h=[7 2520 > > > > 10 3618 > > > > 15 2842] > > > > > > > > I acknowledge this is probably a very straight foward excercise, but I have only really started using matlab and cannot seem to find a way of doing these on the help guide. I know this could be done just by creating a new variable by simply typing the new vaules in as shown in (h), but the data set I have is very much larger than the example shown here. > > > > > > help ISMEMBER > > > use the last column of g as one of its input and use the output to logically index into g. > > > > > > hth > > > Jos > > > > > > Right so I would create a variable from (g) using the last column:a=g(:,2); and use this as an input and use (f) as an output. How would I then logically index this into (g)? > > Almost there: use a and f as inputs of ismember. Look at the output... > > Jos
Thanks alot Jos, I have finally managed to get there on that one. One more small problem, how do you find numbers the same in col 1 as opposed to consecutive numbers:
a=[822 2266 10 822 2266 13 923 3487 12 1060 2086 14 1060 2086 19 1403 2831 15]
so I would want sort (a) into (b):
b=[822 2266 13 923 3487 12 1060 2086 19 1403 2831 15]


Date

Subject

Author

9/30/10


Ian

9/30/10


Jos

9/30/10


Ian

9/30/10


Ian

9/30/10


Jos

9/30/10


Ian


