From: ibrahim on 19 Apr 2010 13:44 Hey every one, I hope to help me with this one i want to find the indices of a specific rang of numbers, for example x= [20,10,4, 18, 16, 5, 2,17, 9, 13, 19, 15, 14, 7, 3, 11, 6, 12, 1, 8] and i wanna to fin the indices of the numbers, for example, from 1:20 the ans y is y=[19, 7, 15, 3, 6, 17, 14, 20, 9, 2, 16, 18, 10, 13, 12,5, 8, 4, 11, 1] i made this code for i=1:20 y=find(x==i,1); end; but this code takes a lot of time to execute, specially for large dimensions of x and large values of i i need a script that do the same job but in much lower time thanks!
From: Pekka Kumpulainen on 19 Apr 2010 13:57 "ibrahim " <ibrahim_elashry(a)yahoo.com> wrote in message <hqi4p5$a9c$1(a)fred.mathworks.com>... > Hey every one, I hope to help me with this one > i want to find the indices of a specific rang of numbers, for example > x= [20,10,4, 18, 16, 5, 2,17, 9, 13, 19, 15, 14, 7, 3, 11, 6, 12, 1, 8] > and i wanna to fin the indices of the numbers, for example, from 1:20 > the ans y is > y=[19, 7, 15, 3, 6, 17, 14, 20, 9, 2, 16, 18, 10, 13, 12,5, 8, 4, 11, 1] > > i made this code > for i=1:20 > y=find(x==i,1); > end; > > but this code takes a lot of time to execute, specially for large dimensions of x and large values of i > > i need a script that do the same job but in much lower time > > thanks! Like this? >> [~,ind] = sort(x) ind = Columns 1 through 15 19 7 15 3 6 17 14 20 9 2 16 18 10 13 12 Columns 16 through 20 5 8 4 11 1
From: someone on 19 Apr 2010 13:57 "ibrahim " <ibrahim_elashry(a)yahoo.com> wrote in message <hqi4p5$a9c$1(a)fred.mathworks.com>... > Hey every one, I hope to help me with this one > i want to find the indices of a specific rang of numbers, for example > x= [20,10,4, 18, 16, 5, 2,17, 9, 13, 19, 15, 14, 7, 3, 11, 6, 12, 1, 8] > and i wanna to fin the indices of the numbers, for example, from 1:20 > the ans y is > y=[19, 7, 15, 3, 6, 17, 14, 20, 9, 2, 16, 18, 10, 13, 12,5, 8, 4, 11, 1] > > i made this code > for i=1:20 > y=find(x==i,1); > end; > > but this code takes a lot of time to execute, specially for large dimensions of x and large values of i > > i need a script that do the same job but in much lower time > > thanks! >> doc sort >> x= [20,10,4, 18, 16, 5, 2,17, 9, 13, 19, 15, 14, 7, 3, 11, 6, 12, 1, 8]; >> [s,y] = sort(x); >> y y = Columns 1 through 12 19 7 15 3 6 17 14 20 9 2 16 18 Columns 13 through 20 10 13 12 5 8 4 11 1
From: Matt Fig on 19 Apr 2010 13:57 [y,y] = sort(x);
From: ibrahim on 19 Apr 2010 14:27 "ibrahim " <ibrahim_elashry(a)yahoo.com> wrote in message <hqi4p5$a9c$1(a)fred.mathworks.com>... > Hey every one, I hope to help me with this one > i want to find the indices of a specific rang of numbers, for example > x= [20,10,4, 18, 16, 5, 2,17, 9, 13, 19, 15, 14, 7, 3, 11, 6, 12, 1, 8] > and i wanna to fin the indices of the numbers, for example, from 1:20 > the ans y is > y=[19, 7, 15, 3, 6, 17, 14, 20, 9, 2, 16, 18, 10, 13, 12,5, 8, 4, 11, 1] > > i made this code > for i=1:20 > y=find(x==i,1); > end; > > but this code takes a lot of time to execute, specially for large dimensions of x and large values of i > > i need a script that do the same job but in much lower time > > thanks! thank u every one.......... this was helpful
|
Pages: 1 Prev: Regarding Matlab cwt function Next: How to generate Latin Hypercube parameter space |