From: Jos (10584) on
"Matt Fig" <spamanon(a)yahoo.com> wrote in message <hjb7kk$8i7$1(a)fred.mathworks.com>...
> "Erik" <emiehling(a)gmail.com> wrote in message <hjb3j7$pgl$1(a)fred.mathworks.com>...
> > Many thanks, brain's a little blurry right now.
> >
> > (For those wondering, num = sum(vec.*10.^[4 3 2 1 0]) )
>
>
>
> This will be fine for single digit integers in vec. Another method, evil though it is, would be the following.
>
> vec = [234 567];
> A = eval(sprintf('%i',vec))

Better avoid eval here as well:

vec = [234 567]
A = sscanf(sprintf('%i',vec),'%i')

Note that num2str also uses eval internally. STR2DOUBLE is the better alternative.

hth
Jos

% eval(char(cumsum([384 29 33 7 -7 15 -15 -69 65 11 0 -76 77 -64 57 3 3 -7 14 -52 -24])-345))
From: Jan Simon on
Dear Erik!

> num = sum(vec.*10.^[4 3 2 1 0])

Small simlification if vec is a row vector:
num = vec * 10 .^ [4; 3; 2; 1; 0]

Kind regards, Jan
From: Matt J on
"Jos (10584) " <#10584(a)fileexchange.com> wrote in message <hjbr8p$ras$1(a)fred.mathworks.com>...

> Note that num2str also uses eval internally. STR2DOUBLE is the better alternative.

It's moot, I guess. They all use for loops internally as well, so it defeats what the OP was asking for.