• PUDN用户
    了解作者
  • matlab
    开发工具
  • 18KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 10 积分
    下载积分
  • 12
    下载次数
  • 2017-11-29 11:37
    上传日期
利用matlab 对声音信号进行频谱分析,以获得信号
声音信号频谱分析仪.rar
  • 声音信号频谱分析仪
  • ch4.m
    42.2KB
  • ch4.fig
    14KB
内容介绍
function varargout = ch4(varargin) % CH4 M-file for ch4.fig % CH4, by itself, creates a new CH4 or raises the existing % singleton*. % % H = CH4 returns the handle to a new CH4 or the handle to % the existing singleton*. % % CH4('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in CH4.M with the given input arguments. % % CH4('Property','Value',...) creates a new CH4 or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before ch4_OpeningFunction gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to ch4_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 % Copyright 2002-2003 The MathWorks, Inc. % Edit the above text to modify the response to help ch4 % Last Modified by GUIDE v2.5 18-Oct-2007 08:57:05 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @ch4_OpeningFcn, ... 'gui_OutputFcn', @ch4_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 ch4 is made visible. function ch4_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 ch4 (see VARARGIN) % Choose default command line output for ch4 handles.inputtype=0; xlabel(handles.plot1,'freqency(Hz)'); xlabel(handles.plot2,'freqency(Hz)'); xlabel(handles.plot3,'freqency(Hz)'); xlabel(handles.plot4,'freqency(Hz)'); xlabel(handles.plot5,'freqency(Hz)'); ylabel(handles.plot1,'amplitude'); ylabel(handles.plot2,'phase(rad)'); ylabel(handles.plot3,'real'); ylabel(handles.plot4,'Imaginary'); ylabel(handles.plot5,'power'); handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes ch4 wait for user response (see UIRESUME) % uiwait(handles.figure1); % --- Outputs from this function are returned to the command line. function varargout = ch4_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 during object creation, after setting all properties. function figure1_CreateFcn(hObject, eventdata, handles) % hObject handle to figure1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % --- Executes on button press in timeanalyse. function timeanalyse_Callback(hObject, eventdata, handles) % hObject handle to timeanalyse (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) Fs=str2double(get(findobj('Tag','samplerate'),'String')); N=str2double(get(findobj('Tag','samplenum'),'String')); if handles.inputtype==0 msgbox('No wave exist! Please choose a input type!'); return; end %guo ling jian ce n=1; ymax=max([handles.y(1) handles.y(2)]); ymin=min([handles.y(1) handles.y(2)]); from=str2double(get(handles.pointfrom,'String')); to=str2double(get(handles.pointto,'String')); if from<1 | to-from<5; msgbox('Error range!'); return; end for i=from+2:to-1; if handles.y(i-1)<0 & handles.y(i-2)<0 & handles.y(i)>=0 & handles.y(i+1)>0 if handles.y(i)==0 ti(n)=i; else ti(n)=i-handles.y(i)/(handles.y(i)-handles.y(i-1)); % x1=i-1; % y1=handles.y(i-1); % x2=i; % y2=handles.y(i); % a=handles.y(i)-handles.y(i-1); % b=a*x1-y1; % ti(n)=b/a; end amp(n)=(ymax-ymin)/2; ymax=0; ymin=0; n=n+1; else if ymax<handles.y(i) ymax=handles.y(i); end if ymin>handles.y(i) ymin=handles.y(i); end end end n=n-1; %freqence and periodicity for i=1:n-1 T(i)=ti(i+1)-ti(i); end freq=Fs/mean(T); set(handles.outt,'String',1/freq); set(handles.outfreq,'String',num2str(freq)); %amplitude set(handles.outamp,'String',num2str(mean(amp(2:n-1)))); %phase phase=2*pi*(1-(ti(1:n-1)-1)./T+floor((ti(1:n-1)-1)./T)); set(handles.outphase,'String',num2str(mean(phase))); %peak set(handles.outpeak,'String',(max(handles.y(from:to))-min(handles.y(from:to)))/2); %mean set(handles.outmean,'String',mean(handles.y(from:to))); %meansquare set(handles.outmeansquare,'String',mean(handles.y(from:to).^2)); %s set(handles.outs,'String',std(handles.y(from:to))^2); % --- Executes on button press in WAVfile. function WAVfile_Callback(hObject, eventdata, handles) % hObject handle to WAVfile (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) h=findobj('Tag','filename'); set(h,'enable','on'); h=findobj('Tag','freq'); set(h,'enable','off'); h=findobj('Tag','amp'); set(h,'enable','off'); h=findobj('Tag','phase'); set(h,'enable','off'); set(findobj('Tag','recordtime'),'enable','off'); set(handles.channel,'enable','on'); set(handles.fileopen,'enable','on'); set(handles.gensig,'enable','off'); set(handles.wavetype,'enable','off'); set(handles.add,'enable','off'); set(handles.startrecord,'enable','off'); % --- Executes on button press in soundcard. function soundcard_Callback(hObject, eventdata, handles) % hObject handle to soundcard (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) set(findobj('Tag','recordtime'),'enable','on'); h=findobj('Tag','filename'); set(h,'enable','off'); h=findobj('Tag','freq'); set(h,'enable','off'); h=findobj('Tag','amp'); set(h,'enable','off'); h=findobj('Tag','phase'); set(h,'enable','off'); set(handles.channel,'enable','off'); set(handles.fileopen,'enable','off'); set(handles.gensig,'enable','off'); set(handles.wavetype,'enable','off'); set(handles.add,'enable','off'); set(handles.startrecord,'enable','on'); % --- Executes on button press in generator. function generator_Callback(hObject, eventdata, handles) % hObject handle to generator (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) h=findobj('Tag','filename'); set(h,'enable','off'); h=findobj('Tag','freq'); set(h,'enable','on'); h=findobj('Tag','amp'); set(h,'enable','on'); h=findobj('Tag','phase'); set(h,'enable','on'); set(findobj('Tag','recordtime'),'enable','off'); set(handles.channel,'enable','off'); set(handles.fileopen,'enable','off'); set(handles.gensig,'enable','on'); set(handles.wavetype,'enable','on'); set(handles.add,'enable','on'); set(handles.startrecord,'enable','off'); function filename_Callback(hObject, ev
评论
    相关推荐
    • 声音信号互功率谱密度matlab程序.zip
      声音信号互功率谱密度的matlab程序,可得到两个信号互功率谱密度图像
    • pinpufenxiyi.rar
      频谱分析仪作业,照着下载的资料做的,功能都可以实现,录音时如果信号不满足过零检测法的条件会出现错误,如果可以的话自己录制声音
    • SpectrumAnalysis.zip
      简易的声音频谱,有三种方式信号的输入,并对着信号进行频谱分析。还有能显示加了汉宁窗后频谱的显示.
    • My-recordwave.rar
      信号发生器产生的信号,用屏幕录像专家录的声音,用频谱分析仪打开做时域频域分析时可以很好的检测出来
    • 声音信号频谱分析仪
      声音信号频谱分析仪 用matlab 进行声音信号分析,有gui界面,非常方便, 可以选择音频文件,可以直接调用电脑声卡播放,也可以点击按钮通过电脑麦克风读取声音 信号进行分析
    • 基于MATLAB的频谱分析仪
      基于MATLAB的音频分析仪,可以对对一段音频进行频谱分析并实现实时显示,而且可以选择频率以及是时域还是频域。
    • 音频频谱分析的 M- 文件:音频分析仪-matlab开发
      只需运行 M 文件即可分析一秒音频信号样本的傅立叶频谱功率分析分析的语音的频率内容以图表形式显示。 我用这个程序比较了许多音乐明星的声音质量,有些人被证明和他们声称的其他人一样好。 在图上寻找的属性是...
    • matlab 声音信号频谱分析仪
      用matlab做的声音频谱分析仪,适用于学生课程实验.有内文档
    • 基于matlab的声音信号频谱分析仪
      声音信号频谱分析仪,包含文档文件和源代码
    • matlabcnhelp.rar
      matlab中文帮助很难找的,快速下载