MATLAB: Sending images using UDP

udp

Hi, I am working on a project that will eventually lead to me receiving IRIG 106 format data from a sounding rocket into MATLAB. To begin to understand the process I am sending data from one copy of MATLAB on one machine to another machine, also running MATLAB, over a wireless connection.
Is there a way to send images (from a CCD so 2 dimensional arrays) using UDP without first reshaping it into a 1 dimensional array?
Also, I would like to be able to send multiple images from one computer to the other which would require the receiving computer to either continuously read or read when the output buffer of the sending machine has data in it. How would I go about doing this?
Thanks

Best Answer

UDP packets are individually byte-stream, so something has to convert from 2D to byte-stream. udp() calls take a linear buffer of information to write, so unless you want to write your own interface to udp (which, as noted is byte-stream), you will need to linearize the information.
If you are looking for something that takes care of the process of converting an array into linear form and folding it back up at the other end, without you having to worry about explicitly coding array sizes and byte orders and whether the individual components for a pixel are written together or entire planes are written as a whole, then you could create XML files and send those. I think you will find, though, that the overhead of creating those is not so much fun. It would, though, have the advantage of being very portable. If you are willing to take a step back from portability you could use one of the File Exchange contributions to serialize