MATLAB: How to read arduino serial data in matlab

arduinoMATLAB

Please i want to know how o read arduino serial monitor data in matlab. In my arduino serial monitor there are z y x coordinates. I want to send this data to matlab and save as a array. Please can anybody tell me what is the arduino coding for that and matlab coding. Please help me

Best Answer

On the Arduino side, use Serial.print or Serial.println . If you use Serial.print remember to send some character (blank, comma) between coordiantes as Serial.print does not add delimiters by itself.
On the MATLAB side, use arduino() to get an arduino object. Use fgets() or fgetl() or fread() to pull in text and then parse the text in various ways, or use fscanf() or textscan() to combine reading and parsing.