在操作某些模块的时候,模块会返回数据到串口,我们通过读取串口的数据,分析模块的运行情况是比较常见的方法。而matlab也有读取串口数据的能力,并加上其强大的绘图能力,可以让数据更为直观的可视化,便于用户更加了解这个模块的运行情况,方便调试。
我画的大概就是这个样子:
这里仅仅设计五个功能,打开串口读取数据、数据可视化、清除图像、关闭窗口、程序运行进度条。
代码如下:
function varargout = shoudongshuju11_10(varargin) gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @shoudongshuju11_10_OpeningFcn, ...
'gui_OutputFcn', @shoudongshuju11_10_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before shoudongshuju11_10 is made visible.
function shoudongshuju11_10_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to shoudongshuju11_10 (s