MATLAB: Do I receive ‘Failed to open serial port COM* to communicate with the board’ or ‘Open fail: Port: COM* is not available. No ports are available.’ error with MATLAB/Simulink support package for Arduino Hardware

MATLABsimulink

Why do I receive the following error when trying to connect to Arduino Hardware with the MATLAB support package?
Failed to open serial port COM6 to communicate with board Uno. Make
sure there is no other MATLAB arduino object for this board. For
troubleshooting, see Arduino Hardware Troubleshooting.
Correspondingly using the Simulink Support Package for Arduino, why do I receive the following error when building a model for the Arduino? ERROR: Open fail: Port: COM* is not available. No ports are available. Use INSTRFIND to determine if other instrument objects are connected to the requested device.

Best Answer

This issue mainly arises when MATLAB tries to connect to the Arduino via more than one connection.
This can happen if there is an existing "arduino" object in the workspace.
Make sure to clear the previous arduino objects before calling the arduino function again, or simulating a model on the Arduino.
To clear an arduino object "my_arduino":
>> clear my_arduino
Additionally check that other MATLAB instances are not connected to the Arduino.
If this does not resolve the error, please contact MathWorks Technical Support at:
Related Question