function varargout = mygui(varargin)
% MYGUI MATLAB code for mygui.fig
% MYGUI, by itself, creates a new MYGUI or raises the existing
% singleton*.
%
% H = MYGUI returns the handle to a new MYGUI or the handle to
% the existing singleton*.
%
% MYGUI('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in MYGUI.M with the given input arguments.
%
% MYGUI('Property','Value',...) creates a new MYGUI or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before mygui_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to mygui_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 mygui
% Last Modified by GUIDE v2.5 07-Oct-2016 09:56:05
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @mygui_OpeningFcn, ...
'gui_OutputFcn', @mygui_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 mygui is made visible.
function mygui_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 mygui (see VARARGIN)
% Choose default command line output for mygui
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes mygui wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = mygui_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 btnPlot.
function btnPlot_Callback(hObject, eventdata, handles)
x=-2:0.2:2;
y=exp(-x.^2);
handles.Line=plot(x, y);
guidata(gcbo, handles);
% 俏蝴綑蒙 縱琶� 枴錦� 頡 �
if get(handles.chbxGridX, 'Value')
%埋琶 階億雛�, 縛窟擘� 溜菴閎靦 鞅璃� 篦錦�
set(gca, 'XGrid', 'on')
else
%埋琶 順蓊�粵, 縛窟擘� 戲擋靦 鞅璃� 篦錦�
set(gca, 'XGrid', 'off')
end
% 俏蝴綑蒙 縱痢� 枴錦� 頡 �
if get(handles.chbxGridY, 'Value')
% 埋琶 階億雛�, 縛窟擘� 溜菴閎靦 鞅璃� 篦錦�
set(gca, 'YGrid', 'on')
else
% 埋琶 順蓊�粵, 縛窟擘� 戲擋靦 鞅璃� 篦錦�
set(gca, 'YGrid', 'off')
end
% 汪複蒙 俠羲曉摘� 溜需熱 羲痞� 獗溜羲曙瘟� 頡縛� 順開� 彙登慢�
set(hObject, 'Enable', 'off')
% 汪複蒙 甽撇錚靦 溜需熱 羲痞� 溜羲曙瘟�
set(handles.btnClear, 'Enable', 'on')
% �� 閱擇蓊�痞粱� 溜需磋 羲痞� 溜羲曙磋憂 頡縛� 頡�隋粵�� 彙登慢�
set(handles.rbMarkCirc, 'Enable', 'on')
set(handles.rbMarkSq, 'Enable', 'on')
set(handles.rbMarkNone, 'Enable', 'on')
if get(handles.rbMarkCirc, 'Value')
% 降錶瘟隋粵 閱擇蓊�痞粱� 影擔綑�-蜥擎�
set(handles.Line, 'Marker', 'o')
end
if get(handles.rbMarkSq, 'Value')
% 降錶瘟隋粵 閱擇蓊�痞粱� 影擔綑�-蒲琴擋靜
set(handles.Line, 'Marker', 's')
end
% 俠撇� 檀錶瘟隋粵瘟廈 閱擇蓊�痞粱� � 複擇滇雒璃� 稞�, 蒙� 獗甦錚隅蝶�
if get(handles.rbMarkCirc, 'Value')
set(handles.rbMarkCirc, 'Enable', 'inactive')
end
if get(handles.rbMarkSq, 'Value')
set(handles.rbMarkSq, 'Enable', 'inactive')
end
if get(handles.rbMarkNone, 'Value')
set(handles.rbMarkNone, 'Enable', 'inactive')
end
% 狙擇滇雒璃� 瘟慮擋 順虛痢瘟� 羲曉蒐
Num=get(handles.pmColor, 'Value');
% 降錶瘟階� 隧稔擘憐廈 燾綏� 鞅璃�
switch Num
case 1
set(handles.Line, 'Color', 'b');
case 2
set(handles.Line, 'Color', 'r');
case 3
set(handles.Line, 'Color', 'g');
end
% 姥鼓義粵徹 溜羲曙� � 擋縈橢鈇羨粳檀� 縉撇蝕
set(handles.pmColor, 'Enable', 'on')
x=-2:0.2:2;
funstr=get(handles.editFun, 'String');
fun=inline(funstr);
y=fun(x);
handles.Line=plot(x,y);
guidata(gcbo, handles);
% 俏蝴綑蒙 縱琶� 枴錦� 頡 �
if get(handles.chbxGridX, 'Value')
%埋琶 階億雛�, 縛窟擘� 溜菴閎靦 鞅璃� 篦錦�
set(gca, 'XGrid', 'on')
else
%埋琶 順蓊�粵, 縛窟擘� 戲擋靦 鞅璃� 篦錦�
set(gca, 'XGrid', 'off')
end
% 俏蝴綑蒙 縱痢� 枴錦� 頡 �
if get(handles.chbxGridY, 'Value')
% 埋琶 階億雛�, 縛窟擘� 溜菴閎靦 鞅璃� 篦錦�
set(gca, 'YGrid', 'on')
else
% 埋琶 順蓊�粵, 縛窟擘� 戲擋靦 鞅璃� 篦錦�
set(gca, 'YGrid', 'off')
end
% 汪複蒙 俠羲曉摘� 溜需熱 羲痞� 獗溜羲曙瘟� 頡縛� 順開� 彙登慢�
set(hObject, 'Enable', 'off')
% 汪複蒙 甽撇錚靦 溜需熱 羲痞� 溜羲曙瘟�
set(handles.btnClear, 'Enable', 'on')
% �� 閱擇蓊�痞粱� 溜需磋 羲痞� 溜羲曙磋憂 頡縛� 頡�隋粵�� 彙登慢�
set(handles.rbMarkCirc, 'Enable', 'on')
set(handles.rbMarkSq, 'Enable', 'on')
set(handles.rbMarkNone, 'Enable', 'on')
if get(handles.rbMarkCirc, 'Value')
% 降錶瘟隋粵 閱擇蓊�痞粱� 影擔綑�-蜥擎�
set(handles.Line, 'Marker', 'o')
end
if get(handles.rbMarkSq, 'Value')
% 降錶瘟隋粵 閱擇蓊�痞粱� 影擔綑�-蒲琴擋靜
set(handles.Line, 'Marker', 's')
end
% 俠撇� 檀錶瘟隋粵瘟廈 閱擇蓊�痞粱� � 複擇滇雒璃� 稞�, 蒙� 獗甦錚隅蝶�
if get(handles.rbMarkCirc, 'Value')
set(handles.rbMarkCirc, 'Enable', 'inactive')
end
if get(handles.rbMarkSq, 'Value')
set(handles.rbMarkSq, 'Enable', 'inactive')
end
if get(handles.rbMarkNone, 'Value')
set(handles.rbMarkNone, 'Enable', 'inactive')
end
% 狙擇滇雒璃� 瘟慮擋 順虛痢瘟� 羲曉蒐
Num=get(handles.pmColor, 'Value');
% 降錶瘟階� 隧稔擘憐廈 燾綏� 鞅璃�
switch Num
case 1
set(handles.Line, 'Color', 'b');
case 2
set(handles.Line, 'Color', 'r');
case 3
set(handles.Line, 'Color', 'g');
end
% 姥鼓義粵徹 溜羲曙� � 擋縈橢鈇羨粳檀� 縉撇蝕
set(handles.pmColor, 'Enable', 'on')
% hObject handle to btnPlot (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in btnClear.
function btnClear_Callback(hObject, eventdata, handles)
cla
% 汪蝌� 甽撇錚靦 溜需熱 羲痞� 獗溜羲曙瘟� 頡縛� 諄撇錦� 褓筮
set(hObject, 'Enable', 'off')
% 汪複蒙 俠羲曉摘� 溜需熱 羲痞� 溜羲曙瘟�
set(handles.btnPlot, 'Enable', 'on')
% 汪複蒙 諄摧琯� 鞅璃� 頡 �
set(gca, 'XGrid', 'off')
% 汪複蒙 諄摧琯� 鞅璃� 頡 �
set(gca, 'YGrid', 'off')
% �� 閱擇蓊�痞粱� 溜需磋 羲痞� 獗溜羲曙磋憂 頡縛� 諄撇錦� 褓筮
set(handles.rbMarkCirc, 'Enable', 'off')
set(handles.rbMarkSq, 'Enable', 'off')
set(handles.rbMarkNone, 'Enable', 'off')
% 囝頜羨粵徹 溜羲曙� � 擋縈橢鈇羨粳� 縉撇蝕
set(handles.pmColor, 'Enable', 'off')
function chbxGridX_Callback(hObject, eventdata, handles)
if get(hObject, 'Value')
% 埋琶 階億雛�, 縛窟擘� 溜菴閎靦 鞅璃� 篦錦�
set(gca, 'XGrid', 'on')
else
% 埋琶 順蓊�粵, 縛窟擘� 戲擋靦 鞅璃� 篦錦�
set(gca, 'XGrid','off')
end
% hObject handle to chbxGridX (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of chbxGridX
% --- Executes on button press in chbxGridY.
function chbxGridY_Callback(hObject, eventdata, handles)
if get(hObject, 'Value')
% 埋琶 階億雛�, 縛窟擘� 溜菴�