7 years, 8 months ago.

Sending arrays via serial to matlab

I am trying to send an array from mbed to Matlab to plot it. How can I send it and how can I configure my program in Matlab to know when the array starts and when is ending to plot it correctly. The array is composed by 2048 floats.

1 Answer

7 years, 8 months ago.

You will need to send a start marker that the matlab code looks for, the values and then an end marker. That way the matlab code will know where the data starts and ends. You could potentially send the matrix size at the start if you want it to be flexible.

Were you going to send the values as text or binary? In terms of mbed code they are very similar. Sending as text is simpler to debug and probably easier for matlab to read but is slower and has the potential to lose accuracy. Sending as binary will retain all the precision and is faster but probably makes the matlab code a more complex.

Beyond that it's hard to give any advice until you've got some code to show us.

Yes, that was my first idea, sending a start marker, for example A and an ending marker for example B, but I thought that solution was a bit low quality.....

The system will be fixed, I am doing an impedance analyzer with 2048 fft points. It is working perfectly to see the maximum frequency, but my idea is sending the whole fft array to matlab to plot it each 5 seconds, more or less.

posted by Sergio Fernandez Santos 16 Aug 2016