matlab绘制点震荡图代码(能出效果,记录思想)

%新建串口对象
t = 1;
s1=serial('COM9','BaudRate',115200); 
%尝试代开串口
try
  fopen(s1);  %打开串口对象
catch err
  fclose(instrfind);  %关闭被占用的串口
  error('请确认选择了正确的串口');  %输出错误提示
end
while true
a = fscanf(s1);  %读取数据
S = regexp(a, " ", "split");
X = str2double(S{2})/16383.75;
comet(t,X);
t=t+1;
pause(0.01)
end

猜你喜欢

转载自blog.csdn.net/ENAIC__suger/article/details/88068063