MATLAB Language Using serial ports Closing a serial port even if lost, deleted or overwritten


Assuming you created the serial port object s as in this example, then to close it


However, sometimes you can accidentally lose the port (e.g. clear, overwrite, change scope, etc...), and fclose(s) will no longer work. The solution is easy


More info at instrfindall().