Prev: winqueryreg
Next: convert video as .wmv to . avi format
From: Jack Branning on 22 Feb 2010 12:40 "Jan Simon" <matlab.THIS_YEAR(a)nMINUSsimon.de> wrote in message <hlueft$t48$1(a)fred.mathworks.com>... > Dear Jack! > > > I've done some more research, and as far as I can tell, lexicographical ordering (when applied to integers) would convert: > > > > 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 > > to > > 1, 10, 11, 12, 2, 3, 4, 5, 6, 7, 8, 9 > > It would be helpful, if you try to obtain such important information *before* you ask questions and let the NG members spend time for replies. > > T = [1, 5, 6, 7, 8, 9, 10, 11, 12, 2, 3, 4] > x = [2, 10, 1, 12, 4, 7] > xT = T(x); > [dum, SortInd] = sort(xT); > xLex = x(SortInd) > > But I still have the impression it could be done easier. Jan Thanks for your help, I really appreciate it! But I would like to point out that my original post does clearly state that I need to lexicographically order the data. My recent explanation of the term was merely an attempt to clarify its meaning. Anyway, thanks again!
From: Nathan on 22 Feb 2010 12:42 On Feb 22, 7:53 am, "Jack Branning" <jbr.nos...(a)nospam.com> wrote: > > SORTROWS is fine to identify matching rows. > > But you can call UNIQUE(A, 'rows') also, which might be easier. > > > BTW: I do not understand "ordered as BxB integer tupels" and why BxB is a 3x3 sliding window. > > > Kind regards, Jan > > I've done some more research, and as far as I can tell, lexicographical ordering (when applied to integers) would convert: > > 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 > > to > > 1, 10, 11, 12, 2, 3, 4, 5, 6, 7, 8, 9 > > Here, all numbers starting with a 1 are at the beginning of the list. Although, logically 12 does not seem smaller than 2, lexicographic ordering works not on the value of the integer in hand, but on the digits that make it up. Also, 10 cannot be smaller than 1 in the ordered list because it is shorter in length (just as the word "forge" would come before the word "forgery" in an English dictionary). > > Does anyone know if MATLAB has a built-in function for this type of ordering? The sort function sorts strings that way within a cell array: A = [1:15]; for ii=1:length(A) newA(ii) = {num2str(A(ii))}; end sort(newA) %%%%%%%%%%%%%%%%%%%%%%%% ans = Columns 1 through 11 '1' '10' '11' '12' '13' '14' '15' '2' '3' '4' '5' Columns 12 through 15 '6' '7' '8' '9' -Nathan
From: Oleg Komarov on 22 Feb 2010 13:07 "Jan Simon" <matlab.THIS_YEAR(a)nMINUSsimon.de> wrote in message <hlueft$t48$1(a)fred.mathworks.com>... > Dear Jack! > > > I've done some more research, and as far as I can tell, lexicographical ordering (when applied to integers) would convert: > > > > 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 > > to > > 1, 10, 11, 12, 2, 3, 4, 5, 6, 7, 8, 9 > > It would be helpful, if you try to obtain such important information *before* you ask questions and let the NG members spend time for replies. > > T = [1, 5, 6, 7, 8, 9, 10, 11, 12, 2, 3, 4] > x = [2, 10, 1, 12, 4, 7] > xT = T(x); > [dum, SortInd] = sort(xT); > xLex = x(SortInd) > > But I still have the impression it could be done easier. Jan % Just sorting the whole T T = [1, 5, 6, 7, 8, 9, 10, 11, 12, 2, 3, 4]; [T, SortInd] = sort(T); xLex = T(SortInd) xLex = 1 10 11 12 2 3 4 5 6 7 8 9 Which is the solution given by Jan. Oleg
From: Walter Roberson on 22 Feb 2010 13:01 Jack Branning wrote: > I've done some more research, and as far as I can tell, lexicographical > ordering (when applied to integers) would convert: > > 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 > > to > > 1, 10, 11, 12, 2, 3, 4, 5, 6, 7, 8, 9 That depends on the locale and the rules in use -- "lexicographical order" rules are not consistent world-wide. For example, in some places the sort order is what you would get if you spelt out the number. > > Here, all numbers starting with a 1 are at the beginning of the list. > Although, logically 12 does not seem smaller than 2, lexicographic > ordering works not on the value of the integer in hand, but on the > digits that make it up. Also, 10 cannot be smaller than 1 in the > ordered list because it is shorter in length (just as the word "forge" > would come before the word "forgery" in an English dictionary). > Does anyone know if MATLAB has a built-in function for this type of > ordering? str2double(cellstr(sortrows(num2str(A.','%-d')))).'
From: Nathan on 22 Feb 2010 13:15 On Feb 22, 10:07 am, "Oleg Komarov" <oleg.komarovRemove.t...(a)hotmail.it> wrote: > "Jan Simon" <matlab.THIS_Y...(a)nMINUSsimon.de> wrote in message <hlueft$t4....(a)fred.mathworks.com>... > > Dear Jack! > > > > I've done some more research, and as far as I can tell, lexicographical ordering (when applied to integers) would convert: > > > > 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 > > > to > > > 1, 10, 11, 12, 2, 3, 4, 5, 6, 7, 8, 9 > > > It would be helpful, if you try to obtain such important information *before* you ask questions and let the NG members spend time for replies. > > > T = [1, 5, 6, 7, 8, 9, 10, 11, 12, 2, 3, 4] > > x = [2, 10, 1, 12, 4, 7] > > xT = T(x); > > [dum, SortInd] = sort(xT); > > xLex = x(SortInd) > > > But I still have the impression it could be done easier. Jan > > % Just sorting the whole T > T = [1, 5, 6, 7, 8, 9, 10, 11, 12, 2, 3, 4]; > [T, SortInd] = sort(T); > xLex = T(SortInd) > xLex = > 1 10 11 12 2 3 4 5 6 7 8 9 > > Which is the solution given by Jan. > > Oleg Can you explain to me why THAT is the correct solution? To me, it looks like a trivial case. My way, although maybe not the fastest, DOES work as a general solution. -Nathan
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 5 Prev: winqueryreg Next: convert video as .wmv to . avi format |