help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

quick way to singles array to byte array


From: George Nychis
Subject: quick way to singles array to byte array
Date: Wed, 28 Jul 2010 22:48:59 -0700

Hi all,

Let's say I have an array of singles, like:
a=[0.923834,0.8234234,0.234234,0.23414]

If I want to convert this to a byte array, where each number is represented by 4 bytes, I've been doing:
b=[];
for i=1:length(a)/2
  b=[b;typecast(single(a((i-1)*2+1)),'uint8');typecast(single(a((i-1)*2+2)),'uint8')]
end

Is there an easier, less complex way of doing this?

Thanks!
George

reply via email to

[Prev in Thread] Current Thread [Next in Thread]