⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gui_signal.m

📁 电子社08年的《精通MATLABG UI设计》一书的所有代码
💻 M
字号:
function varargout = gui_signal(varargin)%GUI_SIGNAL M-file for gui_signal.fig%      GUI_SIGNAL, by itself, creates a new GUI_SIGNAL or raises the existing%      singleton*.%%      H = GUI_SIGNAL returns the handle to a new GUI_SIGNAL or the handle to%      the existing singleton*.%%      GUI_SIGNAL('Property','Value',...) creates a new GUI_SIGNAL using the%      given property value pairs. Unrecognized properties are passed via%      varargin to gui_signal_OpeningFcn.  This calling syntax produces a%      warning when there is an existing singleton*.%%      GUI_SIGNAL('CALLBACK') and GUI_SIGNAL('CALLBACK',hObject,...) call the%      local function named CALLBACK in GUI_SIGNAL.M with the given input%      arguments.%%      *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_signal% Last Modified by GUIDE v2.5 19-Aug-2007 10:39:44% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name',       mfilename, ...                   'gui_Singleton',  gui_Singleton, ...                   'gui_OpeningFcn', @gui_signal_OpeningFcn, ...                   'gui_OutputFcn',  @gui_signal_OutputFcn, ...                   'gui_LayoutFcn',  [], ...                   'gui_Callback',   []);if nargin && ischar(varargin{1})   gui_State.gui_Callback = str2func(varargin{1});endif 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_signal is made visible.function gui_signal_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   unrecognized PropertyName/PropertyValue pairs from the%            command line (see VARARGIN)% Choose default command line output for gui_signalhandles.output = hObject;% Update handles structureguidata(hObject, handles);% UIWAIT makes gui_signal wait for user response (see UIRESUME)% uiwait(handles.figure1);% --- Outputs from this function are returned to the command line.function varargout = gui_signal_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 structurevarargout{1} = handles.output;function f1_input_Callback(hObject, eventdata, handles)% hObject    handle to f1_input (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 f1_input as text%        str2double(get(hObject,'String')) returns contents of f1_input as a doublefunction f2_input_Callback(hObject, eventdata, handles)% hObject    handle to f2_input (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 f2_input as text%        str2double(get(hObject,'String')) returns contents of f2_input as a doublefunction t_input_Callback(hObject, eventdata, handles)% hObject    handle to t_input (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 t_input as text%        str2double(get(hObject,'String')) returns contents of t_input as a double% --- Executes on button press in plot_pushbutton.function plot_pushbutton_Callback(hObject, eventdata, handles)% hObject    handle to plot_pushbutton (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% Get user input from GUIf1 = str2double(get(handles.f1_input,'String'));f2 = str2double(get(handles.f2_input,'String'));t = eval(get(handles.t_input,'String'));% Calculate datax = sin(2*pi*f1*t) + sin(2*pi*f2*t);y = fft(x,512);m = y.*conj(y)/512;f = 1000*(0:256)/512;% Create frequency plotaxes(handles.frequency_axes) % Select the proper axesplot(f,m(1:257))set(handles.frequency_axes,'XMinorTick','on')grid on% Create time plotaxes(handles.time_axes) % Select the proper axesplot(t,x)set(handles.time_axes,'XMinorTick','on')grid on% --- Executes during object creation, after setting all properties.function f1_input_CreateFcn(hObject, eventdata, handles)% hObject    handle to f1_input (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns calledset(gcbo,'String','120');% 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 during object creation, after setting all properties.function f2_input_CreateFcn(hObject, eventdata, handles)% hObject    handle to f2_input (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns calledset(gcbo,'String','60');% 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 during object creation, after setting all properties.function t_input_CreateFcn(hObject, eventdata, handles)% hObject    handle to t_input (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns calledset(gcbo,'String','0:0.001:0.25');% 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 plot_menu_Callback(hObject, eventdata, handles)% hObject    handle to plot_menu (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)plot_pushbutton_Callback(hObject, eventdata, handles)% --------------------------------------------------------------------function file_menu_Callback(hObject, eventdata, handles)% hObject    handle to file_menu (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% --------------------------------------------------------------------function close_menu_Callback(hObject, eventdata, handles)% hObject    handle to close_menu (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)close

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -