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

📄 spectrumexpogui.m

📁 非常好的数字处理教程
💻 M
📖 第 1 页 / 共 4 页
字号:
function varargout = spectrumexpogui(varargin)% SPECTRUMEXPOGUI.m-file for spectrumexpogui.fig%      SPECTRUMEXPOGUI, by itself, creates a new SPECTRUMEXPOGUI or raises the existing%      singleton*.%%      H = SPECTRUMEXPOGUI returns the handle to a new SPECTRUMEXPOGUI or the handle to%      the existing singleton*.%%      SPECTRUMEXPOGUI('CALLBACK',hObject,eventData,handles,...) calls the local%      function named CALLBACK in SPECTRUMEXPOGUI.M with the given input arguments.%%      SPECTRUMEXPOGUI('Property','Value',...) creates a new SPECTRUMEXPOGUI or raises the%      existing singleton*.  Starting from the left, property value pairs are%      applied to the GUI before spectrumexpogui_OpeningFunction gets called.  An%      unrecognized property name or invalid value makes property application%      stop.  All inputs are passed to spectrumexpogui_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 19-Apr-2004 11:58:43% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name',       mfilename, ...                   'gui_Singleton',  gui_Singleton, ...                   'gui_OpeningFcn', @spectrumexpogui_OpeningFcn, ...                   'gui_OutputFcn',  @spectrumexpogui_OutputFcn, ...                   'gui_LayoutFcn',  @spectrumexpogui_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 spectrumexpogui_OpeningFcn(hObject, eventdata, handles, varargin)handles.output = hObject;guidata(hObject, handles);set(gcf,'UserData',handles);spectrumexpofn;%if strcmp(get(hObject,'Visible'),'off')%	update_Callback(hObject, eventdata, handles)%end% --- Outputs from this function are returned to the command line.function varargout = spectrumexpogui_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)	spectrumexpofn '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));	spectrumexpofn '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));	spectrumexpofn '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);	spectrumexpofn '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);	spectrumexpofn '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);	spectrumexpofn '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);	spectrumexpofn '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);	spectrumexpofn '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);	spectrumexpofn '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);	spectrumexpofn '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);	spectrumexpofn '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);	spectrumexpofn '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);	spectrumexpofn '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);	spectrumexpofn '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);	spectrumexpofn '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)	spectrumexpofn '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)	spectrumexpofn '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));	spectrumexpofn '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));

⌨️ 快捷键说明

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