From: almalki_98 on
Hi everybody,

I want to convert a logical array to any type of nuemeric array.
But I do not know how.
Any help is appreciated

Amal
From: James Tursa on
almalki_98(a)hotmail.com wrote in message <d6a362f3-cbc8-4d09-adcf-361cd1a8d071(a)m3g2000yqf.googlegroups.com>...
> Hi everybody,
>
> I want to convert a logical array to any type of nuemeric array.
> But I do not know how.
> Any help is appreciated
>
> Amal

A = rand(5) % a double array
LA = A < .5 % a logical array
DLA = double(LA) % logical array turned into a double array

James Tursa
From: us on
almalki_98(a)hotmail.com wrote in message <d6a362f3-cbc8-4d09-adcf-361cd1a8d071(a)m3g2000yqf.googlegroups.com>...
> Hi everybody,
>
> I want to convert a logical array to any type of nuemeric array.
> But I do not know how.
> Any help is appreciated
>
> Amal

a hint:

help double;

us
From: Jan Simon on
Dear Amal!

Another idea:
help cast
Jan
From: us on
"Jan Simon" <matlab.THIS_YEAR(a)nMINUSsimon.de> wrote in message <hhqbdm$t58$1(a)fred.mathworks.com>...
> Dear Amal!
>
> Another idea:
> help cast
> Jan

well...

v=false(1,100000);
tic;
for i=1:1000
vd=double(v);
end
t1=toc;
tic;
for i=1:1000
vd=cast(v,'double');
end
t2=toc;
% wintel sys: i2c/2*2.6ghz/2gb/winxp.sp3.32/r2009b
disp([t1;t2]);
%{
0.20388 % <- DOUBLE
0.73422 % <- CAST
%}

....just a thought, as usual...
us