【新手向】手把手带你入门的MATLAB的GUI编程实例

准备工作

打开MATLAB,在下方命令行窗口里输入代码guide,敲下回车。

然后的内容我就不赘述了,网上有很多很好的入门链接,这里随便摘录几篇:

关于如何创建控件、使用控件,这里不再赘述,看看上面的资料应该都懂了。这里主要列举一下一些常见的问题

  • 问:如何使用这些控件?
    • 答:如下图,把左面你想要的控件用鼠标拖动过来就行了
      在这里插入图片描述
  • 问:如何编辑控件?
    • 答:这个可以参考前面我列举的链接。实际上,双击你的控件,会弹出下图的框,鼠标滚轮到底,就有如下窗口。下图列举了可编辑文本框三个常用的选项。
      在这里插入图片描述
  • 问:如何让对应的控件使能?或者说我该怎么用这些控件?
    • 答:以普通按钮为例,你按下按钮后,就会执行Callback函数。所以,你只需要对Callback函数里写上你想执行的功能,每当你按下按钮时,Callback函数里的代码就会被执行一遍。找到回调函数的办法是:右键你想寻找的控件,然后查看回调->Callback

在这里插入图片描述

编程实例

实现目标

  1. 正弦波信号,生成,指定频率 f,幅度 A,相位 Φ 的正弦波,时长为 L,采样频率 fs 为 1000 Hz,并在 GUI窗口中显示。

  2. 方波信号,生成指定幅度 A、占空比 a 的方波信号,时长为 L,采样频率 fs 为 1000 Hz,并在 GUI 窗口 中显示。

  3. 混合正弦信号,生成一频率为 f1,另一频率为 f2,幅度均为 A,时长为 L,相位为 0 的混合正弦波信号,采 样频率 fs 为 1000 Hz,并在 GUI 窗口中显示。

  4. 生成服从高斯分布的白噪声序列,时长为 L,方差为 σ2,并在 GUI 窗口中显示。

  5. 生成服从均匀分布的白噪声序列,时长为 L,方差为 σ2,并在 GUI 窗口中显示。

界面配置

我就以本次大作业的代码为例子,这里偷个懒,我就不写具体如何操作的了,直接放结果,读者只需拖动工具栏,配置得和我一样就行。注意控件命名也要一致,改命名就是改编辑菜单栏里的Tag属性,没列举的代表命名不重要。

在这里插入图片描述

可编辑文本框的Callback函数

前面讲了如何找到对应控件的Callback函数,只需右键你想寻找的控件,然后查看回调->Callback即可。当然,也可以直接在m文件里找到对应的代码。然后以控件3为例,将对应的Callback函数替换为如下代码(所有edit1~7都需要如此替换,内容都是一致的):

function edit3_Callback(hObject, eventdata, handles)

    a=str2num(get(hObject,'String')); % 得到其中的字符串并将其转换为数字
    if isempty(a) % 判断是否为数据,若否,则将其设置为0
        set(hObject,'String','0');
    end
    guidata(hObject,handles); % 更新数据

大概解释一下这些代码的意思。

  • get(hObject,'String')是获取该可编辑文本框里的文本内容,返回值是string类型
  • str2num(get(hObject,'String'))是将获取的文本内容转换为数字类型,如果无法转换,就返回空
  • 如果返回值为空,为了防止程序出错,我们应该将其值设置为某个安全的值(例如0),这里使用函数set(hObject,'String','0')实现
  • guidata(hObject,handles)是更新数据,方便其他控件调用(后面会讲到)

弹出式菜单的配置

将弹出式菜单内容如此配置,因为是5行,就会有5个选项:
在这里插入图片描述
为了方便,在选择对应菜单操作时,就可以直接分配一个默认的初始化值。因此,将弹出式菜单的Callback函数如此配置(当然,不这么做也是不影响程序的正常运行的):

function popupmenu1_Callback(hObject, eventdata, handles)

num = get(handles.popupmenu1, 'Value');
if num == 1 % 正弦波,f1=50,A=2,P=0,L=0.1
	set(handles.edit1,'Enable','on');
	set(handles.edit1,'String','50');
	set(handles.edit2,'Enable','on');
	set(handles.edit2,'String','2');
	set(handles.edit3,'Enable','on');
	set(handles.edit3,'String','0');
	set(handles.edit4,'Enable','on');
	set(handles.edit4,'String','0.1');
	set(handles.edit5,'Enable','off');
	set(handles.edit6,'Enable','off');
	set(handles.edit7,'Enable','off');
elseif num == 2 % 方波,f1=50,A=2,P=0,L=0.1,a=30,f2=0,s2=0
	set(handles.edit1,'Enable','on');
	set(handles.edit1,'String','50');
	set(handles.edit2,'Enable','on');
	set(handles.edit2,'String','2');
	set(handles.edit3,'Enable','off');
	set(handles.edit4,'Enable','on');
	set(handles.edit4,'String','0.1');
	set(handles.edit5,'Enable','on');
	set(handles.edit5,'String','30');
	set(handles.edit6,'Enable','off');
	set(handles.edit7,'Enable','off');
elseif num == 3 % 混合正弦,f1=50,A=2,P=0,L=0.1,a=0,f2=40,s2=0
	set(handles.edit1,'Enable','on');
	set(handles.edit1,'String','50');
	set(handles.edit2,'Enable','on');
	set(handles.edit2,'String','2');
	set(handles.edit3,'Enable','off');
	set(handles.edit4,'Enable','on');
	set(handles.edit4,'String','0.1');
	set(handles.edit5,'Enable','off');
	set(handles.edit6,'String','40');
	set(handles.edit7,'Enable','off');
elseif num == 4 % 高斯白,f1=0,A=0,P=0,L=0.1,a=0,f2=0,s2=1
	set(handles.edit1,'Enable','off');
	set(handles.edit2,'Enable','off');
	set(handles.edit3,'Enable','off');
	set(handles.edit4,'Enable','on');
	set(handles.edit4,'String','0.1');
	set(handles.edit5,'Enable','off');
	set(handles.edit6,'Enable','off');
	set(handles.edit7,'Enable','on');
	set(handles.edit7,'String','1');
elseif num == 5 % 均匀白,f1=0,A=0,P=0,L=0.1,a=0,f2=0,s2=1
	set(handles.edit1,'Enable','off');
	set(handles.edit2,'Enable','off');
	set(handles.edit3,'Enable','off');
	set(handles.edit4,'Enable','on');
	set(handles.edit4,'String','0.1');
	set(handles.edit5,'Enable','off');
	set(handles.edit6,'Enable','off');
	set(handles.edit7,'Enable','on');
	set(handles.edit7,'String','1');
else
    disp('弹出式菜单空间范围错误!');
end

这里没什么好说的,应该都能看懂吧。num = get(handles.popupmenu1, 'Value')是获取选项菜单当前值是几,并且执行如下初始化操作。其中set(handles.edit1,'String','0')就是把可编辑文本控件1的值置为0,set(handles.edit5,'Enable','off')是禁止该可编辑文本的更改,set(handles.edit5,'Enable','on')是打开该可编辑文本的更改。

显示图形——按钮的Callback函数

显示图形本质上就是plot就行了。但是plot的参数都在可编辑文本框里,那么如何获取呢?仿照上面的例子,使用get函数就可以了。所以,下面的代码看起来吓人,其实前面都只是在获取其他控件的值而已,重头戏其实只有一行plot

function pushbutton1_Callback(hObject, eventdata, handles)

    f1=str2double(get(handles.edit1,'String')); % 获得频率f1
    A=str2double(get(handles.edit2,'String')); % 获得幅度A
    P=str2double(get(handles.edit3,'String')); % 获得相位P
    L=str2double(get(handles.edit4,'String')); % 获得时长L
    a=str2double(get(handles.edit5,'String')); % 获得占空比a%
    f2=str2double(get(handles.edit6,'String')); % 获得频率f2
    s2=str2double(get(handles.edit7,'String')); % 获得方差s2
    x=0:1/1000:L; % 定义x范围以及步长
    num = get(handles.popupmenu1, 'Value'); % 获取选项菜单值
    if num == 1 % 正弦
        y=A*sin(2*pi*f1*x+P); % 计算该函数y值
    elseif num == 2 % 方波
        y=zeros(1,length(x));
        y(mod(x,1/f1)<1/f1*(a/100))=1;
    elseif num == 3 % 正弦混合
        y=A*sin(2*pi*f1*x)+A*sin(2*pi*f2*x);
    elseif num == 4 % 高斯白
        y=randn(1,length(x))*sqrt(s2);
    elseif num == 5 % 均匀白
        y=(rand(1,length(x))-0.5)*sqrt(s2*12);
    else
        y=zeros(1,length(x));
    end
    plot(x,y); % 绘图并显示在绘图区

效果演示

在这里插入图片描述
在这里插入图片描述

全部代码汇总

之前为了简略起见,有些省略了的细节,为了方便对照,将全部代码备份如下(含系统自动生成的注释),用于备查。

function varargout = GUI_test1(varargin)
% GUI_TEST1 MATLAB code for GUI_test1.fig
%      GUI_TEST1, by itself, creates a new GUI_TEST1 or raises the existing
%      singleton*.
%
%      H = GUI_TEST1 returns the handle to a new GUI_TEST1 or the handle to
%      the existing singleton*.
%
%      GUI_TEST1('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in GUI_TEST1.M with the given input arguments.
%
%      GUI_TEST1('Property','Value',...) creates a new GUI_TEST1 or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before GUI_test1_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to GUI_test1_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help GUI_test1

% Last Modified by GUIDE v2.5 11-Jan-2021 15:32:18

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @GUI_test1_OpeningFcn, ...
                   'gui_OutputFcn',  @GUI_test1_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 GUI_test1 is made visible.
function GUI_test1_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 GUI_test1 (see VARARGIN)

% Choose default command line output for GUI_test1
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes GUI_test1 wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = GUI_test1_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;


% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
    f1=str2double(get(handles.edit1,'String')); % 获得频率f1
    A=str2double(get(handles.edit2,'String')); % 获得幅度A
    P=str2double(get(handles.edit3,'String')); % 获得相位P
    L=str2double(get(handles.edit4,'String')); % 获得时长L
    a=str2double(get(handles.edit5,'String')); % 获得占空比a%
    f2=str2double(get(handles.edit6,'String')); % 获得频率f2
    s2=str2double(get(handles.edit7,'String')); % 获得方差s2
    x=0:1/1000:L; % 定义x范围以及步长
    num = get(handles.popupmenu1, 'Value'); % 获取选项菜单值
    if num == 1 % 正弦
        y=A*sin(2*pi*f1*x+P); % 计算该函数y值
    elseif num == 2 % 方波
        y=zeros(1,length(x));
        y(mod(x,1/f1)<1/f1*(a/100))=1;
    elseif num == 3 % 正弦混合
        y=A*sin(2*pi*f1*x)+A*sin(2*pi*f2*x);
    elseif num == 4 % 高斯白
        y=randn(1,length(x))*sqrt(s2);
    elseif num == 5 % 均匀白
        y=(rand(1,length(x))-0.5)*sqrt(s2*12);
    else
        y=zeros(1,length(x));
    end
    plot(x,y); % 绘图并显示在绘图区

% --- If Enable == 'on', executes on mouse press in 5 pixel border.
% --- Otherwise, executes on mouse press in 5 pixel border or over pushbutton1.
function pushbutton1_ButtonDownFcn(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)



function edit1_Callback(hObject, eventdata, handles)
% hObject    handle to edit1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit1 as text
%        str2double(get(hObject,'String')) returns contents of edit1 as a double

    a=str2num(get(hObject,'String')); % 得到其中的字符串并将其转换为数字
    if isempty(a) % 判断是否为数据,若否,则将其设置为50
        set(hObject,'String','50');
    end
    guidata(hObject,handles); % 更新数据


% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit2_Callback(hObject, eventdata, handles)
% hObject    handle to edit2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit2 as text
%        str2double(get(hObject,'String')) returns contents of edit2 as a double

    a=str2num(get(hObject,'String')); % 得到其中的字符串并将其转换为数字
    if isempty(a) % 判断是否为数据,若否,则将其设置为2
        set(hObject,'String','2');
    end
    guidata(hObject,handles); % 更新数据


% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit3_Callback(hObject, eventdata, handles)
% hObject    handle to edit3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit3 as text
%        str2double(get(hObject,'String')) returns contents of edit3 as a double

    a=str2num(get(hObject,'String')); % 得到其中的字符串并将其转换为数字
    if isempty(a) % 判断是否为数据,若否,则将其设置为0
        set(hObject,'String','0');
    elseif a>100||a<0 % 防止错误数据范围
        set(hObject,'String','30');
    end
    guidata(hObject,handles); % 更新数据


% --- Executes during object creation, after setting all properties.
function edit3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit4_Callback(hObject, eventdata, handles)
% hObject    handle to edit4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit4 as text
%        str2double(get(hObject,'String')) returns contents of edit4 as a double

    a=str2num(get(hObject,'String')); % 得到其中的字符串并将其转换为数字
    if isempty(a) % 判断是否为数据,若否,则将其设置为0.1
        set(hObject,'String','0.1');
    end
    guidata(hObject,handles); % 更新数据


% --- Executes during object creation, after setting all properties.
function edit4_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit5_Callback(hObject, eventdata, handles)
% hObject    handle to edit5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit5 as text
%        str2double(get(hObject,'String')) returns contents of edit5 as a double

    a=str2num(get(hObject,'String')); % 得到其中的字符串并将其转换为数字
    if isempty(a) % 判断是否为数据,若否,则将其设置为0.3
        set(hObject,'String','0.3');
    end
    guidata(hObject,handles); % 更新数据


% --- Executes during object creation, after setting all properties.
function edit5_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu1 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu1

num = get(handles.popupmenu1, 'Value');
if num == 1 % 正弦波,f1=50,A=2,P=0,L=0.1
	set(handles.edit1,'Enable','on');
	set(handles.edit1,'String','50');
	set(handles.edit2,'Enable','on');
	set(handles.edit2,'String','2');
	set(handles.edit3,'Enable','on');
	set(handles.edit3,'String','0');
	set(handles.edit4,'Enable','on');
	set(handles.edit4,'String','0.1');
	set(handles.edit5,'Enable','off');
	set(handles.edit6,'Enable','off');
	set(handles.edit7,'Enable','off');
elseif num == 2 % 方波,f1=50,A=2,P=0,L=0.1,a=30,f2=0,s2=0
	set(handles.edit1,'Enable','on');
	set(handles.edit1,'String','50');
	set(handles.edit2,'Enable','on');
	set(handles.edit2,'String','2');
	set(handles.edit3,'Enable','off');
	set(handles.edit4,'Enable','on');
	set(handles.edit4,'String','0.1');
	set(handles.edit5,'Enable','on');
	set(handles.edit5,'String','30');
	set(handles.edit6,'Enable','off');
	set(handles.edit7,'Enable','off');
elseif num == 3 % 混合正弦,f1=50,A=2,P=0,L=0.1,a=0,f2=40,s2=0
	set(handles.edit1,'Enable','on');
	set(handles.edit1,'String','50');
	set(handles.edit2,'Enable','on');
	set(handles.edit2,'String','2');
	set(handles.edit3,'Enable','off');
	set(handles.edit4,'Enable','on');
	set(handles.edit4,'String','0.1');
	set(handles.edit5,'Enable','off');
	set(handles.edit6,'String','40');
	set(handles.edit7,'Enable','off');
elseif num == 4 % 高斯白,f1=0,A=0,P=0,L=0.1,a=0,f2=0,s2=1
	set(handles.edit1,'Enable','off');
	set(handles.edit2,'Enable','off');
	set(handles.edit3,'Enable','off');
	set(handles.edit4,'Enable','on');
	set(handles.edit4,'String','0.1');
	set(handles.edit5,'Enable','off');
	set(handles.edit6,'Enable','off');
	set(handles.edit7,'Enable','on');
	set(handles.edit7,'String','1');
elseif num == 5 % 均匀白,f1=0,A=0,P=0,L=0.1,a=0,f2=0,s2=1
	set(handles.edit1,'Enable','off');
	set(handles.edit2,'Enable','off');
	set(handles.edit3,'Enable','off');
	set(handles.edit4,'Enable','on');
	set(handles.edit4,'String','0.1');
	set(handles.edit5,'Enable','off');
	set(handles.edit6,'Enable','off');
	set(handles.edit7,'Enable','on');
	set(handles.edit7,'String','1');
else
    disp('弹出式菜单空间范围错误!');
end
    


% --- Executes during object creation, after setting all properties.
function popupmenu1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit6_Callback(hObject, eventdata, handles)
% hObject    handle to edit6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit6 as text
%        str2double(get(hObject,'String')) returns contents of edit6 as a double

    a=str2num(get(hObject,'String')); % 得到其中的字符串并将其转换为数字
    if isempty(a) % 判断是否为数据,若否,则将其设置为40
        set(hObject,'String','40');
    end
    guidata(hObject,handles); % 更新数据



% --- Executes during object creation, after setting all properties.
function edit6_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit7_Callback(hObject, eventdata, handles)
% hObject    handle to edit7 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit7 as text
%        str2double(get(hObject,'String')) returns contents of edit7 as a double

    a=str2num(get(hObject,'String')); % 得到其中的字符串并将其转换为数字
    if isempty(a) % 判断是否为数据,若否,则将其设置为1
        set(hObject,'String','1');
    end
    guidata(hObject,handles); % 更新数据




% --- Executes during object creation, after setting all properties.
function edit7_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit7 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

  • 58
    点赞
  • 268
    收藏
    觉得还不错? 一键收藏
  • 6
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值