From: Juliette Salexa on
Is there a way to avoid the forloop here:

for i=1:10000000
b(i)=matrix2num(a(i,:));
end

?

Perhaps using cell arrays ?
From: Matt Fig on
And what is MATRIX2NUM? I sure don't have it...
From: Roger Stafford on
"Juliette Salexa" <juliette.physicist(a)gmail.com> wrote in message <hqqhm2$ipj$1(a)fred.mathworks.com>...
> Is there a way to avoid the forloop here:
>
> for i=1:10000000
> b(i)=matrix2num(a(i,:));
> end
>
> ?
>
> Perhaps using cell arrays ?
--------------------
n = size(a,2);
b = a*10.^((n-1:-1:0).');

I am assuming your matrix2num is the one written by Aman Siddiqi at:
http://www.mathworks.nl/matlabcentral/fileexchange/7264
which in this case converts decimal digits to decimal numbers.

Roger Stafford
From: Matt Fig on
Oh, if that is the case:

% Data
a = magic(3)

% Engine
b = sum(a.*repmat(10.^(size(a,2)-1:-1:0),size(a,1),1),2)
From: Matt Fig on
"Roger Stafford" <ellieandrogerxyzzy(a)mindspring.com.invalid> wrote in message
> --------------------
> n = size(a,2);
> b = a*10.^((n-1:-1:0).');
> Roger Stafford

Much nicer!