Skip to main content
2 of 3
added 6 characters in body; edited title
dda
  • 1.6k
  • 1
  • 12
  • 18

Questions on how to connect Arduino to Matlab through the serial port

I have an Arduino board with Intel Edison on it. I have tried to read data in Arduino from MatLab through the serial port. I'm sure the Arduino board is working because when I use the serial monitor from Arduino, it shows the data read from the Arduino board. My command is like this in Arduino:

reading = Wire.read(); Serial.println(reading)

I got errors in Matlab when I tried to work with these piece of code:

s=serial('COM4'); set(s,'BaudRate',9600); fopen(s);

MatLab complains that "Port: COM4 is not available. No ports are available. Use INSTRFIND to determine if other instrument objects are connected to the requested device." I have tried with "instrfind()" in matlab and got this:

Instrument Object Array

Index: Type: Status: Name:
1 serial closed Serial-COM4 2 serial closed Serial-COM4 3 serial open Serial-COM4 4 serial closed Serial-COM4 5 serial closed Serial-COM4

I still can't get any clue on this. Can anybody help me?