arduino与matlab联调出现问题

1.问题描述
arduino读取数据没有问题,用matlab调用arduino的数据来画图时,说端口不可用,这里我使用的是(com4).

错误使用 serial/fopen (line 72)
打开失败: Port: COM4 is not available. No ports are available.
Use INSTRFIND to determine if other instrument objects are connected to the requested device.
出错 test (line 12)
fopen(s); %打开串口对象s

2.解决方法
这四句代码写在前面,作用是找到打开的端口并关闭和删除,我是这样理解的
if ~isempty(instrfind)
     fclose(instrfind);
      delete(instrfind);
end
https://www.mathworks.com/matlabcentral/answers/257651-failed-to-open-serial-port-com3-to-communicate-with-board-uno


注意:不要在matlab代码里写clc 和clear,要不然画出来的只是一个类似阶跃信号的图。clc和clear 可以在命令行里写。
原文地址:https://www.cnblogs.com/neverguveip/p/9457310.html