Code Comments
Programming Forum and web based access to our favorite programming groups.Hi, What is the difference between : sort(10^precision*A) and sort(A) Seems that I misunderstood something :( Jérôme
Post Follow-up to this messageJérôme wrote: > > > Hi, > > What is the difference between : > > sort(10^precision*A) > > and > > sort(A) > > Seems that I misunderstood something :( > Jérôme Oops, I forgot the <round>. Doh! precision=3; [idx,idx]=sort(round(10^precision*A),'de scend'); A_sort=A(idx)
Post Follow-up to this messageSteve Amphlett wrote: > > Oops, I forgot the <round>. Doh! > precision=3; > [idx,idx]=sort(round(10^precision*A),'de scend'); > A_sort=A(idx) OK Steve, perhaps I need coffee but : what is the difference between : sort(round(10^precision*A)) and sort(A) I take a coffee... Jérôme
Post Follow-up to this messageJérôme wrote: > > > Steve Amphlett wrote: > > > > OK Steve, perhaps I need coffee but : > > what is the difference between : > > sort(round(10^precision*A)) > > and > > sort(A) For the example input given, nothing. But try this: precision=3; A=rand(1000,1); [idx1,idx1]=sort(round(10^precision*A),' descend'); [idx2,idx2]=sort(A,'descend'); all(idx1==idx2) ans = 0 ans = 628
Post Follow-up to this messageAfter a great black coffee : I know differences between the two codes you post. But I think these differences match the "or" in the question : sortedA = [1.2000; 1.013 1.0123 or 1.0124 1.0124 1.0123 1.0112]; So to me, in that case, both give the same (good) result ! Jérôme
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.