📄 sinexpogui.m
字号:
function varargout = sinexpogui(varargin)% SINEXPOGUI.m-file for sinexpogui.fig% SINEXPOGUI, by itself, creates a new SINEXPOGUI or raises the existing% singleton*.%% H = SINEXPOGUI returns the handle to a new SINEXPOGUI or the handle to% the existing singleton*.%% SINEXPOGUI('CALLBACK',hObject,eventData,handles,...) calls the local% function named CALLBACK in SINEXPOGUI.M with the given input arguments.%% SINEXPOGUI('Property','Value',...) creates a new SINEXPOGUI or raises the% existing singleton*. Starting from the left, property value pairs are% applied to the GUI before sinexpogui_OpeningFunction gets called. An% unrecognized property name or invalid value makes property application% stop. All inputs are passed to sinexpogui_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% Last Modified by GUIDE v2.5 31-Mar-2004 13:31:28% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @sinexpogui_OpeningFcn, ... 'gui_OutputFcn', @sinexpogui_OutputFcn, ... 'gui_LayoutFcn', @sinexpogui_LayoutFcn, ... 'gui_Callback', []);if nargin & isstr(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 sinesumgui2 is made visible.function sinexpogui_OpeningFcn(hObject, eventdata, handles, varargin)handles.output = hObject;guidata(hObject, handles);set(gcf,'UserData',handles);sinexpofn;%if strcmp(get(hObject,'Visible'),'off')% update_Callback(hObject, eventdata, handles)%end% --- Outputs from this function are returned to the command line.function varargout = sinexpogui_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 popupmenu1_CreateFcn(hObject, eventdata, handles) if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end set(hObject, 'String', {'Sum', 'Product'});function popupmenu1_Callback(hObject, eventdata, handles) sinexpofn 'update';function freq1_CreateFcn(hObject, eventdata, handles) if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); endfunction freq2_CreateFcn(hObject, eventdata, handles) if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); endfunction amp1_CreateFcn(hObject, eventdata, handles) if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); endfunction amp2_CreateFcn(hObject, eventdata, handles) if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); endfunction phase1_CreateFcn(hObject, eventdata, handles)if ispc set(hObject,'BackgroundColor','white');else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));endfunction phase2_CreateFcn(hObject, eventdata, handles)if ispc set(hObject,'BackgroundColor','white');else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));end% Executes on textbox entryfunction freq1_Callback(hObject, eventdata, handles) freq1 = str2double(get(hObject,'String')); if freq1 < 20.1 freq1 = 20.1; elseif freq1 > 22042 freq1 = 22042; end set(handles.freq1,'String',num2str(freq1)); set(handles.freq1slider,'Value',log2(freq1)); sinexpofn 'update';function freq2_Callback(hObject, eventdata, handles) freq2 = str2double(get(hObject,'String')); if freq2 < 20.1 freq2 = 20.1; elseif freq2 > 22042 freq2 = 22042; end set(handles.freq2,'String',num2str(freq2)); set(handles.freq2slider,'Value',log2(freq2)); sinexpofn 'update';function amp1_Callback(hObject, eventdata, handles) amp1 = str2double(get(hObject,'String')); if amp1 < 0 amp1 = 0; elseif amp1 > 2 amp1 = 2; end set(handles.amp1,'String',num2str(amp1)); set(handles.amp1slider,'Value',amp1); sinexpofn 'update';function amp2_Callback(hObject, eventdata, handles) amp2 = str2double(get(hObject,'String')); if amp2 < 0 amp2 = 0; elseif amp2 > 2 amp2 = 2; end set(handles.amp2,'String',num2str(amp2)); set(handles.amp2slider,'Value',amp2); sinexpofn 'update';function phase1_Callback(hObject, eventdata, handles) phase1 = str2double(get(hObject,'String')); if phase1 < -180 while phase1 < -180 phase1 = phase1 + 360; end elseif phase1 > 180 while phase1 > 180 phase1 = phase1 - 360; end end set(handles.phase1,'String',num2str(phase1)); set(handles.phase1slider,'Value',phase1); sinexpofn 'update';function phase2_Callback(hObject, eventdata, handles) phase2 = str2double(get(hObject,'String')); if phase2 < -180 while phase2 < -180 phase2 = phase2 + 360; end elseif phase2 > 180 while phase2 > 180 phase2 = phase2 - 360; end end set(handles.phase2,'String',num2str(phase2)); set(handles.phase2slider,'Value',phase2); sinexpofn 'update';% --- Executes during object creation, after setting all properties.function freq1slider_CreateFcn(hObject, eventdata, handles)usewhitebg = 1;if usewhitebg set(hObject,'BackgroundColor',[.9 .9 .9]);else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));end% --- Executes on slider movement.function freq1slider_Callback(hObject, eventdata, handles) freq1 = num2str(2^get(hObject,'Value')); set(handles.freq1,'String',freq1); sinexpofn 'update';% --- Executes during object creation, after setting all properties.function amp1slider_CreateFcn(hObject, eventdata, handles)usewhitebg = 1;if usewhitebg set(hObject,'BackgroundColor',[.9 .9 .9]);else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));end% --- Executes on slider movement.function amp1slider_Callback(hObject, eventdata, handles) amp1 = num2str(get(hObject,'Value')); set(handles.amp1,'String',amp1); sinexpofn 'update';% --- Executes during object creation, after setting all properties.function phase1slider_CreateFcn(hObject, eventdata, handles)usewhitebg = 1;if usewhitebg set(hObject,'BackgroundColor',[.9 .9 .9]);else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));end% --- Executes on slider movement.function phase1slider_Callback(hObject, eventdata, handles) phase1 = num2str(get(hObject,'Value')); set(handles.phase1,'String',phase1); sinexpofn 'update';% --- Executes during object creation, after setting all properties.function freq2slider_CreateFcn(hObject, eventdata, handles)usewhitebg = 1;if usewhitebg set(hObject,'BackgroundColor',[.9 .9 .9]);else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));end% --- Executes on slider movement.function freq2slider_Callback(hObject, eventdata, handles) freq2 = num2str(2^get(hObject,'Value')); set(handles.freq2,'String',freq2); sinexpofn 'update';% --- Executes during object creation, after setting all properties.function amp2slider_CreateFcn(hObject, eventdata, handles)usewhitebg = 1;if usewhitebg set(hObject,'BackgroundColor',[.9 .9 .9]);else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));end% --- Executes on slider movement.function amp2slider_Callback(hObject, eventdata, handles) amp2 = num2str(get(hObject,'Value')); set(handles.amp2,'String',amp2); sinexpofn 'update';% --- Executes during object creation, after setting all properties.function phase2slider_CreateFcn(hObject, eventdata, handles)usewhitebg = 1;if usewhitebg set(hObject,'BackgroundColor',[.9 .9 .9]);else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));end% --- Executes on slider movement.function phase2slider_Callback(hObject, eventdata, handles) phase2 = num2str(get(hObject,'Value')); set(handles.phase2,'String',phase2); sinexpofn 'update';% --- Executes during object creation, after setting all properties.function offset_CreateFcn(hObject, eventdata, handles)if ispc set(hObject,'BackgroundColor','white');else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));endfunction offset_Callback(hObject, eventdata, handles) offset = str2double(get(hObject,'String')); if offset < 0 offset = 0; elseif offset > 1 offset = 1; end set(handles.offset,'String',num2str(offset)); set(handles.offsetslider,'Value',offset); sinexpofn 'update';% --- Executes during object creation, after setting all properties.function offsetslider_CreateFcn(hObject, eventdata, handles)usewhitebg = 1;if usewhitebg set(hObject,'BackgroundColor',[.9 .9 .9]);else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));end% --- Executes on slider movement.function offsetslider_Callback(hObject, eventdata, handles) offset = num2str(get(hObject,'Value')); set(handles.offset,'String',offset); sinexpofn 'update';%% --- Executes on button press in updatebutton.%function updatebutton_Callback(hObject, eventdata, handles)% update_Callback(hObject, eventdata, handles)% --- Executes on button press in play.function play_Callback(hObject, eventdata, handles) sinexpofn 'play';% --- Executes during object creation, after setting all properties.function plotype_CreateFcn(hObject, eventdata, handles)if ispc set(hObject,'BackgroundColor','white');else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));end% --- Executes on selection change in plotype.function plotype_Callback(hObject, eventdata, handles) sinexpofn 'update';% --- Executes during object creation, after setting all properties.function Fstext_CreateFcn(hObject, eventdata, handles)if ispc set(hObject,'BackgroundColor','white');else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));endfunction Fstext_Callback(hObject, eventdata, handles) Fs = str2double(get(hObject,'String')); if (Fs > 44100) Fs = 44100; end if (Fs < 21) Fs = 21; end set(handles.Fsslider,'Value',log2(Fs)); set(handles.Fstext,'String',num2str(Fs)); sinexpofn 'update';% --- Executes during object creation, after setting all properties.function Fsslider_CreateFcn(hObject, eventdata, handles)usewhitebg = 1;if usewhitebg set(hObject,'BackgroundColor',[.9 .9 .9]);else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));end% --- Executes on slider movement.function Fsslider_Callback(hObject, eventdata, handles) Fs = ceil(2^get(hObject,'Value')); if (Fs > 44100) Fs = 44100; end if (Fs < 0) Fs = 0; end set(handles.Fsslider,'Value',log2(Fs)); set(handles.Fstext,'String',num2str(Fs)); sinexpofn 'update';% --- Executes during object creation, after setting all properties.function durationtext_CreateFcn(hObject, eventdata, handles)if ispc set(hObject,'BackgroundColor','white');else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));endfunction durationtext_Callback(hObject, eventdata, handles) duration = str2double(get(hObject,'String')); if duration <= 0 duration = 0.01; set(handles.durationtext,'String',num2str(duration)); end set(handles.durationslider,'Value',duration); sinexpofn 'update';% --- Executes during object creation, after setting all properties.function durationslider_CreateFcn(hObject, eventdata, handles)usewhitebg = 1;if usewhitebg set(hObject,'BackgroundColor',[.9 .9 .9]);else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));end% --- Executes on slider movement.function durationslider_Callback(hObject, eventdata, handles) duration = num2str(get(hObject,'Value')); set(handles.durationtext,'String',duration); sinexpofn 'update';% --- Executes on button press in gridbox.function gridbox_Callback(hObject, eventdata, handles) sinexpofn 'update';% --- Executes on button press in plot1box.function plot1box_Callback(hObject, eventdata, handles) sinexpofn 'update';% --- Executes on button press in plot2box.function plot2box_Callback(hObject, eventdata, handles) sinexpofn 'update';% --- Executes on button press in spectrumbutton.function spectrumbutton_Callback(hObject, eventdata, handles) sinexpofn 'spectrum';% --- Executes on button press in interpbox.function interpbox_Callback(hObject, eventdata, handles) sinexpofn 'update';% --- Executes on button press in samplebox.function samplebox_Callback(hObject, eventdata, handles) sinexpofn 'update';% --- Executes when user attempts to close sinexpogui_fig.function sinexpogui_fig_CloseRequestFcn(hObject, eventdata, handles)% hObject handle to sinexpogui_fig (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hint: delete(hObject) closes the figuredelete(hObject);% --------------------------------------------------------------------function Untitled_1_Callback(hObject, eventdata, handles)% hObject handle to Untitled_1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -