Sending an array from MATLAB to Arduino

Hi all!

I am rather new to Arduino and also to MATLAB and I would like to ask for help.

I developed a code for the arduino, which reads serial input data, and stores the integer values in it.

It works perfectly when I write all numbers in the serial monitor (seperated by commas) and send it as one.

But I can not make MATLAB to send a similar message (multiple integer values, seperated by anything).

(My probe array what I copy-paste in to the serial monitor is the following:
“10,0,15,1,1,0,0,150,0,0,1,0,0,150,0,0,1,0,0,150,0,0,0,0,0,33,0,0,0,0,0,33,0,0,0,0,0,33,0,0,170”)

Here is my Arduino code:

void loop()
{

  if (Serial.available()>0)                 // Process incoming message if serial data available
    {
      for (int i=0; i<41; i++)              // Load the 34 integers to the temporary array.
        {
          SERIAL_DATA[i]=Serial.parseInt(); // parseInt() function loads first valid integes.
        }                                   // Numbers may be separated anything other than numbers.
      
      for (int j=0; j<41; j++)
        {
          Serial.print("SERIAL_DATA[");
          Serial.print(j);
          Serial.print("]= ");
          Serial.println(SERIAL_DATA[j]);
        }
      while(Serial.available()>0)           // Reads out leftover data (like: '/n', etc.).
        {
          Serial.read();
        }
}

How can I send the same (or similar) message to my arduino?
(If I am correct, my code only needs 41 integer values, seperated by anything other then numbers.)

Thank you very much in advance!

Zancot

Have a look at the examples in Serial Input Basics. They are simple and reliable. They receive all the data before trying to parse the data. There is also a parse example that could be adapted to put your values into your array.

If you have the choice use the style of data in the 3rd example for maximum reliability.

...R

I hope that you've noticed that this is NOT the Matlab forum. Your Matlab question is better asked on some other forum.