Matlab设计图形用户界面
设计的比较简易,通过修改对象属性代码等可以更精细。
function varargout = Guide2(varargin)
% Simple example of Matlab GUI, by wanglei
% Last Modified by GUIDE v2.5 10-Nov-2016 17:04:09
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @Guide2_OpeningFcn, ...
'gui_OutputFcn', @Guide2_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 Guide2 is made visible.
function Guide2_OpeningFcn(hObject, eventdata, handles, varargin)
% Choose default command line output for Guide2
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes Guide2 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = Guide2_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
% --------------------------------------------------------------------
function file_1_Callback(hObject, eventdata, handles)
% --------------------------------------------------------------------
function Untitled_5_Callback(hObject, eventdata, handles)
% --------------------------------------------------------------------
function Untitled_1_Callback(hObject, eventdata, handles)
% --------------------------------------------------------------------
function Untitled_3_Callback(hObject, eventdata, handles)
% --------------------------------------------------------------------
function Untitled_4_Callback(hObject, eventdata, handles)
% --------------------------------------------------------------------
function Untitled_6_Callback(hObject, eventdata, handles)
% --------------------------------------------------------------------
function Untitled_7_Callback(hObject, eventdata, handles)
% --------------------------------------------------------------------
function Untitled_8_Callback(hObject, eventdata, handles)
% --------------------------------------------------------------------
function Untitled_9_Callback(hObject, eventdata, handles)
% --- Executes on selection change in listbox1.
function listbox1_Callback(hObject, eventdata, handles)
% Hints: contents = cellstr(get(hObject,'String')) returns listbox1 contents as cell array
% contents{get(hObject,'Value')} returns selected item from listbox1
% --- Executes during object creation, after setting all properties.
function listbox1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
am_1=get(handles.radiobutton1,'value');
am_2=get(handles.radiobutton2,'value');
if am_1==1
am=5;
else
am=10;
end
fre1=get(handles.listbox1,'string')
whos fre1
n=get(handles.listbox1,'value');
fre=eval(fre1(n,:));
x=0:0.1:10;
axes(handles.axes1);
plot(am*sin(fre*x));
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
close
% --------------------------------------------------------------------
function Untitled_10_Callback(hObject, eventdata, handles)
% --------------------------------------------------------------------
function Untitled_11_Callback(hObject, eventdata, handles)
% --------------------------------------------------------------------
function Untitled_12_Callback(hObject, eventdata, handles)
% --------------------------------------------------------------------
function Untitled_13_Callback(hObject, eventdata, handles)
% --------------------------------------------------------------------
function Untitled_14_Callback(hObject, eventdata, handles)
% --------------------------------------------------------------------
function Untitled_15_Callback(hObject, eventdata, handles)
% --- Executes on button press in pushbutton3.
function im1 = pushbutton3_Callback(hObject, eventdata, handles)
[fname,pname] = uigetfile('*.*');
im1 = imread([pname,fname]);
axes(handles.axes2);
imshow(im1);
% --- Executes during object creation, after setting all properties.
function axes1_CreateFcn(hObject, eventdata, handles)
% --- Executes on button press in listbox2.
function listbox2_Callback(hObject, eventdata, handles)
% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
close
% --- Executes on button press in pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
filt1 = get(handles.listbox2,'string');
%whos filter1
%celldisp(filter1)
n = get(handles.listbox2,'value');
filter1 = char(filt1{n});
im1 = getimage(handles.axes2);
%H=fspecial('gaussian',n,sigma);
H = fspecial(filter1);
im2 = imfilter(im1,H);
imshow(im2);