【语
1 简介
开发一种将Matlab仿真应用于语音信号处理中的教学方法,通过编写程序上机实验帮助学生理解语音信号处理的基本原理和方法,介绍在语音信号模拟生成的仿真实现,以图形化的方式使学生对于抽象的结果有直观的认识.
2 部分代码
function varargout = untitledb(varargin)% UNTITLEDB MATLAB code for untitledb.fig% UNTITLEDB, by itself, creates a new UNTITLEDB or raises the existing% singleton*.%% H = UNTITLEDB returns the handle to a new UNTITLEDB or the handle to% the existing singleton*.%x2=A2*sawtooth(2*pi/T2*(t+P2),F2);;%三角波信号;end;switch(get(handles.popupmenu3,'value'));case 1x3=0;set(handles.edit12,'String','0');set(handles.edit13,'String','0');set(handles.edit14,'String','0');case 2A3=str2num(get(handles.edit12,'String'));F3=str2num(get(handles.edit13,'String'));P3=str2num(get(handles.edit14,'String'));T3=str2num(get(handles.edit45,'String'));x3=A3*sin(2*pi*F3*t+P3/180*pi);case 3A3=str2num(get(handles.edit12,'String'));F3=str2num(get(handles.edit13,'String'));P3=str2num(get(handles.edit14,'String'));T3=str2num(get(handles.edit45,'String'));x3=A3*square(2*pi/T3*(t+P3),F3);%方波信号;case 4A3=str2num(get(handles.edit12,'String'));F3=str2num(get(handles.edit13,'String'));P3=str2num(get(handles.edit14,'String'));T3=str2num(get(handles.edit45,'String'));x3=A3*sawtooth(2*pi/T3*(t+P3),F3);;%三角波信号;end;switch(get(handles.popupmenu4,'value'));case 1x4=0;set(handles.edit15,'String','0');set(handles.edit16,'String','0');set(handles.edit17,'String','0');case 2A4=str2num(get(handles.edit15,'String'));F4=str2num(get(handles.edit16,'String'));P4=str2num(get(handles.edit17,'String'));T4=str2num(get(handles.edit46,'String'));x4=A4*sin(2*pi*F4*t+P4/180*pi);case 3A4=str2num(get(handles.edit15,'String'));F4=str2num(get(handles.edit16,'String'));P4=str2num(get(handles.edit17,'String'));T4=str2num(get(handles.edit46,'String'));x4=A4*square(2*pi/T4*(t+P4),F4);%方波信号;case 4A4=str2num(get(handles.edit15,'String'));F4=str2num(get(handles.edit16,'String'));P4=str2num(get(handles.edit17,'String'));T4=str2num(get(handles.edit46,'String'));x4=A4*sawtooth(2*pi/T4*(t+P4),F4);;%三角波信号;end;switch(get(handles.popupmenu5,'value'));case 1x5=0;set(handles.edit18,'String','0');set(handles.edit19,'String','0');set(handles.edit20,'String','0');case 2A5=str2num(get(handles.edit18,'String'));F5=str2num(get(handles.edit19,'String'));P5=str2num(get(handles.edit20,'String'));T5=str2num(get(handles.edit47,'String'));x5=A5*sin(2*pi*F5*t+P5/180*pi);case 3A5=str2num(get(handles.edit18,'String'));F5=str2num(get(handles.edit19,'String'));P5=str2num(get(handles.edit20,'String'));T5=str2num(get(handles.edit47,'String'));x5=A5*square(2*pi/T5*(t+P5),F5);%方波信号;case 4A5=str2num(get(handles.edit18,'String'));F5=str2num(get(handles.edit19,'String'));P5=str2num(get(handles.edit20,'String'));T5=str2num(get(handles.edit47,'String'));x5=A5*sawtooth(2*pi/T5*(t+P5),F5);;%三角波信号;end;if (get(handles.checkbox1,'Value'))x8=str2num(get(handles.edit27,'String'))*t/t;elsex8=0;end;if (get(handles.checkbox2,'Value'))A9=str2num(get(handles.edit28,'String'));F9=str2num(get(handles.edit29,'String'));P9=str2num(get(handles.edit30,'String'));x9=chirp(t,A9,F9,P9);%chirp信号elsex9=0;end;if (get(handles.checkbox3,'Value'))A10=str2num(get(handles.edit31,'String'));P10=str2num(get(handles.edit33,'String'));x10=wgn(A10,N,P10);elsex10=0;end;x=x1+x2+x3+x4+x5+x7+x8+x9+x10;if(~isempty(diff(x)))axes(handles.axes1)plot(t,x);hmm=abs(max(x)-min(x));ylim([min(x)-0.5*hmm max(x)+0.5*hmm]);title('信号x(t)');y1=fft(x,N);y2=fftshift(y1);f=(0:N-1)*fs/N-fs/2;mag=abs(y2)/N*2;if(mod(N,2)==1)mag(1,N/2+0.5)=mag(1,N/2+0.5)/2;elseend;axes(handles.axes2);plot(f,mag);ylim([1.5*min(mag) 1.5*max(mag) ]);title('频谱幅度特性|H(jw)|');axes(handles.axes3)plot(f,angle(y2));a3=str2num(get(handles.edit39,'String'));b3=str2num(get(handles.edit40,'String'));ylim([1.5*min(angle(y2)) 1.5*max(angle(y2))]);title('频谱相位特性\Phi(H(jw))');axes(handles.axes4);pwelch(x);elseaxes(handles.axes1);plot([a,b],[x,x]);axes(handles.axes2);plot([-fs/2,fs/2],[0,0]);axes(handles.axes3);plot([-fs/2,fs/2],[0,0]);axes(handles.axes4);plot([0,pi],[0,0]);axis tight;end;function edit6_Callback(hObject, eventdata, handles)% hObject handle to edit6 (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 edit6 as text% str2double(get(hObject,'String')) returns contents of edit6 as a double% --- Executes during object creation, after setting all properties.function edit6_CreateFcn(hObject, eventdata, handles)% hObject handle to edit6 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% 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');endfunction edit7_Callback(hObject, eventdata, handles)% hObject handle to edit7 (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 edit7 as text% str2double(get(hObject,'String')) returns contents of edit7 as a double% --- Executes during object creation, after setting all properties.function edit7_CreateFcn(hObject, eventdata, handles)% hObject handle to edit7 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% 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');endfunction edit8_Callback(hObject, eventdata, handles)% hObject handle to edit8 (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 edit8 as text% str2double(get(hObject,'String')) returns contents of edit8 as a double% --- Executes during object creation, after setting all properties.function edit8_CreateFcn(hObject, eventdata, handles)% hObject handle to edit8 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% 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');endfunction edit9_Callback(hObject, eventdata, handles)% hObject handle to edit9 (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 edit9 as text% str2double(get(hObject,'String')) returns contents of edit9 as a double% --- Executes during object creation, after setting all properties.function edit9_CreateFcn(hObject, eventdata, handles)% hObject handle to edit9 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% 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');endfunction edit10_Callback(hObject, eventdata, handles)% hObject handle to edit10 (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 edit10 as text% str2double(get(hObject,'String')) returns contents of edit10 as a double% --- Executes during object creation, after setting all properties.function edit10_CreateFcn(hObject, eventdata, handles)% hObject handle to edit10 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% 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');endfunction edit11_Callback(hObject, eventdata, handles)% hObject handle to edit11 (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 edit11 as text% str2double(get(hObject,'String')) returns contents of edit11 as a double% --- Executes during object creation, after setting all properties.function edit11_CreateFcn(hObject, eventdata, handles)% hObject handle to edit11 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% 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
3 仿真结果

4 参考文献
[1]王孟杰, 庞昂博, 杨一军. Matlab在语音信号处理实验教学中的应用[J]. 牡丹江师范学院学报:自然科学版, 2011(1):3.
博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。
部分理论引用网络文献,若有侵权联系博主删除。
本文介绍了一种使用Matlab进行语音信号处理的教学方法,通过编写程序进行实验,帮助学生理解和掌握语音信号处理的基本原理及方法。文章还提供了部分Matlab代码示例,并展示了仿真结果。
5万+

被折叠的 条评论
为什么被折叠?



