Changing the data type of an array



Hi,

I have a very specific question. I am sure there must be a way to do
this efficiently yet I have been unable to do so.

I am using MATLAB to communicate with a remote instrument (logic
analyzer). That instrument provides the result of the measurement as
an array of unsigned bytes. But as I know that it is indeed an array
of 16 bit signed integers (int16), I have to go through a data
conversion process. To do the conversion, currently I am reading the
byte array with a "for" loop which builds a new array whose length is
have the original array length. As you can imagine, this is way too
slow when the data measured is large. I wonder if there is a
better/faster way of doing this with MATLAB (I bet there is, but I
have been unable to find it). For instance, if I was doing this in C,
I would just use an integer pointer that would point to the byte
array. Any help would be appreciated.

Thanks,

Fernando.
.



Relevant Pages

  • Re: Byte swapping efficiently
    ... signed integers into an array is about the best I can expect. ... Data(DataX, DataY) = ByteSwap ... DataX = DataX + 1 ... The Datatwo-dimensional array is declared as private single, ...
    (microsoft.public.vb.general.discussion)
  • Re: An interesting new RNG.
    ... for signed integers. ... All you need is an array, ... Most implementations would ask for a few seeds from which the ... A nice idea for an RNG. ...
    (comp.lang.c)
  • PowerBasic rocks!
    ... I just tried a test loop to add an array of 64 million 16-bit signed ... integers into an array of 32-bit signed integers. ... I could rewrite this using pointers and it might be faster. ...
    (sci.electronics.design)
  • Re: PowerBasic rocks!
    ... integers into an array of 32-bit signed integers. ... We'll acquire 64M samples once a second or so, so the signal averaging ... Well, the old array iterator LODSW, followed by ops, followed by ... I don't know MMX instructions, so you'll have to look that up ...
    (sci.electronics.design)
  • Re: Changing the data type of an array
    ... But as I know that it is indeed an array ... > of 16 bit signed integers, I have to go through a data ... > conversion process. ... every pair of bytes as a signed int16. ...
    (comp.soft-sys.matlab)