From: Bluebird on 25 Feb 2010 12:54 Hello All.. I have a big matrix of binary values and i want to change it to decimal, following is what i am doing and this is very slow for me as i am required to apply the transformation on thousands of matrices X=ones([10000,3]); % assume one the binary matrix of 10,000 binary number tic F=bin2dec(num2str(X,'%-1d')); toc this the code that i am doing and on average the time it takes is around 0.3-0.4 seconds, this is really slow for me, Can you please suggest a faster coding.. Many many thanks
From: Rune Allnor on 25 Feb 2010 13:25 On 25 Feb, 18:54, "Bluebird " <wlo...(a)ryerson.ca> wrote: > Hello All.. > > I have a big matrix of binary values and i want to change it to decimal, following is what i am doing and this is very slow for me as i am required to apply the transformation on thousands of matrices > > X=ones([10000,3]); % assume one the binary matrix of 10,000 binary number > > tic > F=bin2dec(num2str(X,'%-1d')); > toc > > this the code that i am doing and on average the time it takes is around 0.3-0.4 seconds, this is really slow for me, > > Can you please suggest a faster coding.. Not with matlab. This is the kind of thing you would need to do in C or C++ (or even assembler) to gain significant speed. But then, have the computer run overninght. One hour is 3600 seconds, so you should be able to convert about 5000 matrices per hour. Rune
From: Walter Roberson on 25 Feb 2010 13:44 Bluebird wrote: > I have a big matrix of binary values and i want to change it to decimal, > following is what i am doing and this is very slow for me as i am > required to apply the transformation on thousands of matrices > > > X=ones([10000,3]); % assume one the binary matrix of 10,000 binary number > > tic > F=bin2dec(num2str(X,'%-1d')); > toc F=bin2dec(char(X + '0')); Though if you only have 3 columns, I would suggest time-testing F = X * [4 2 1].'; and F = X(:,1)*4 + X(:,2)*2 + X(:,3); and there's probably also a sum(bsxfun()) solution that might come out faster.
From: Bluebird on 25 Feb 2010 14:03 Walter Roberson <roberson(a)hushmail.com> wrote in message <hm6gdq$ker$1(a)canopus.cc.umanitoba.ca>... > Bluebird wrote: > > > I have a big matrix of binary values and i want to change it to decimal, > > following is what i am doing and this is very slow for me as i am > > required to apply the transformation on thousands of matrices > > > > > > X=ones([10000,3]); % assume one the binary matrix of 10,000 binary number > > > > tic > > F=bin2dec(num2str(X,'%-1d')); > > toc > > F=bin2dec(char(X + '0')); > > > Though if you only have 3 columns, I would suggest time-testing > > F = X * [4 2 1].'; > > and > > F = X(:,1)*4 + X(:,2)*2 + X(:,3); > > and there's probably also a sum(bsxfun()) solution that might come out > faster. Thank you Walter the time dropped from 0.3 to 0.00016 :) thank you so much... Yeah the thing is i want have more than 10 column so i can make look-up-table for the values and just multiply .... Thanks again.....
From: Bluebird on 25 Feb 2010 14:04 Rune Allnor <allnor(a)tele.ntnu.no> wrote in message <0d07159e-5c6d-4a37-87d2-867fbbd6e685(a)e7g2000yqf.googlegroups.com>... > On 25 Feb, 18:54, "Bluebird " <wlo...(a)ryerson.ca> wrote: > > Hello All.. > > > > I have a big matrix of binary values and i want to change it to decimal, following is what i am doing and this is very slow for me as i am required to apply the transformation on thousands of matrices > > > > X=ones([10000,3]); % assume one the binary matrix of 10,000 binary number > > > > tic > > F=bin2dec(num2str(X,'%-1d')); > > toc > > > > this the code that i am doing and on average the time it takes is around 0.3-0.4 seconds, this is really slow for me, > > > > Can you please suggest a faster coding.. > Thank you Rune > Not with matlab. > > This is the kind of thing you would need to do in C or C++ > (or even assembler) to gain significant speed. > > But then, have the computer run overninght. One hour is > 3600 seconds, so you should be able to convert about 5000 > matrices per hour. > > Rune
|
Pages: 1 Prev: Replace strings without loop Next: Appendix of PSD inverse post |