Communication between Matlab and Arduino

Hallo,

I would like for example that the Arduino itself (!) Adds two vectors. The sequence:

  1. Arduino continuously gets vectors
  2. Arduino calculates this
  3. Return it

How can I realize points 1 and 3? The data are to come from Matlab.

Thanks a lot

  1. Arduino receives values via the Serial interface
  2. Arduino transmits results via the Serial interface

What facilities does matlab have for transmitting information? Can it write results to a file? to stdout? Can it read/write a USB port?

UKHeliBob:

  1. Arduino receives values via the Serial interface
  2. Arduino transmits results via the Serial interface

Yes i know, but how can i realize it?

selim94:
Yes i know, but how can i realize it?

Do you know how to send from Matlab using the serial interface ?
Do you know how to read the serial input to the Arduino ?
Do you know how to send from the Arduino using the serial interface ?

What have you tried ?

Hi,

my Problem is that Matlab has this Error, when i want to communicate with SerialCommunication:

Warning: Unsuccessful read: A timeout occurred before the Terminator was reached

The reason is that the serial communication is not fast enough to READ and PRINT in the same scope (unnessecary if it is a unlimited loop).

 void loop(){
      
     matData = Serial.read();
     matData++;
     Serial.println(matData);

}

This is not possible. When i read the Data in the void() scope, it isnt declared in my loop() scope anymore. How can i fix this Problem? Maybe someone has a solution for this problem.

Thanks a lot

There is no variable called Data in the snippet you posted

i declared it before the void() scope. int matData;

Your question still doesn't make any sense BECAUSE YOU ONLY POSTED A SNIPPET

What does serialRead() return when no data is available?

What happens when you increment it?

What happens if you print things as fast as you can?

Common threads merged.