function varargout = test(varargin)
% TEST M-file for test.fig
% TEST, by itself, creates a new TEST or raises the existing
% singleton*.
%
% H = TEST returns the handle to a new TEST or the handle to
% the existing singleton*.
%
% TEST('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in TEST.M with the given input arguments.
%
% TEST('Property','Value',...) creates a new TEST or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before test_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to test_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
% Edit the above text to modify the response to About test
% Last Modified by GUIDE v2.5 06-Jul-2008 21:44:54
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @test_OpeningFcn, ...
'gui_OutputFcn', @test_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 test is made visible.
function test_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 test (see VARARGIN)
% Choose default command line output for test
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes test wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = test_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 on button press in LOAD.
function LOAD_Callback(hObject, eventdata, handles)
% hObject handle to LOAD (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global x fs t
[x,fs] = wavread('test.wav');
t = (1:length(x))/fs;
t8 = length(x)*8;
t8 = (1:t8)/fs;
Bs = 0.5*fs;
save('data.mat','x','fs','t','t8');
N = length(x);
X=fft(x,N);%进行fft变换
mag=abs(X);%求幅值
f=(0:length(X)-1)'*fs/length(X);%进行对应的频率转换
subplot(2,1,1,'position',[0.3 0.57 0.6 0.3]);
plot(t,x) %时域图
xlabel('时间');
ylabel('幅值');
axis([min(t) max(t) min(x) max(x)]);
subplot(2,1,2,'position',[0.3 0.2 0.6 0.3]);
plot(f,mag);%做频谱图
xlabel('频率');
ylabel('幅值');
axis([0 max(f) 0 1.1*max(abs(X)) ]);
set(handles.LOAD,'enable','off');
set(handles.PCM,'enable','on');
set(handles.Play_origin,'enable','on');
set(handles.text1,'String','测试音频文件波形如图所示');
% --- Executes on button press in PCM.
function PCM_Callback(hObject, eventdata, handles)
% hObject handle to PCM (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
load data.mat;
x1 = x./max(abs(x));
sxx = floor( x1 * 4096 );
y = pcm_encode(sxx);
save('data.mat','y','-append');
subplot(1,1,1,'position',[0.3 0.2 0.6 0.65]);
plot(t8,y);
xlabel('时间');
ylabel('幅值');
axis([0 0.1 -1 2]);
set(handles.dePCM,'enable','on');
set(handles.QAM,'enable','on');
set(handles.text1,'String','经过PCM编码后,形成二进制码流');
% --- Executes on button press in QAM.
function QAM_Callback(hObject, eventdata, handles)
% hObject handle to QAM (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
prompt={'信道SNR:'};
name='Input';
numlines=1;
defaultanswer={'20'};
answer=inputdlg(prompt,name,numlines,defaultanswer);
if ~isempty(answer) ,
result = str2num(answer{1,1});
load data.mat;
Qt = my_qammod(y);
Qr = awgn(Qt,result);
yy= my_qamdemod(Qr);
save('data.mat','yy','-append');
subplot(1,1,1,'position',[0.3 0.2 0.6 0.65]);
plot(t8,yy);
xlabel('时间');
ylabel('幅值');
axis([0 0.1 -1 2]);
set(handles.compare2,'enable','on');
set(handles.text1,'String','PCM信号通过QAM调制,送到AWGN信道,再经过解调还原为PCM信号');
end
% --- Executes on button press in dePCM.
function dePCM_Callback(hObject, eventdata, handles)
% hObject handle to dePCM (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
load data.mat;
xx = pcm_decode(y,max(abs(x)));
save('data.mat','xx','-append');
N = length(xx);
XX=fft(xx,N);%进行fft变换
mag=abs(XX);%求幅值
f=(0:length(XX)-1)'*fs/length(XX);%进行对应的频率转换
subplot(2,1,1,'position',[0.3 0.57 0.6 0.3]);
plot(t,xx) %时域图
xlabel('时间');
ylabel('幅值');
axis([min(t) max(t) min(xx) max(xx)]);
subplot(2,1,2,'position',[0.3 0.2 0.6 0.3]);
plot(f,mag);%做频谱图
xlabel('频率');
ylabel('幅值');
axis([0 max(f) 0 1.1*max(abs(XX)) ]);
set(handles.compare1,'enable','on');
set(handles.Play_arrive,'enable','on');
set(handles.text1,'String','对恢复的PCM信号进行PCM解码,就是接收到的信号');
% --- Executes on button press in compare1.
function compare1_Callback(hObject, eventdata, handles)
% hObject handle to compare1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% compare between original signal and arrived signal
load data.mat
subplot(2,1,1,'position',[0.3 0.57 0.6 0.3]);
plot(t,x)
xlabel('时间');
ylabel('幅值');
axis([min(t) max(t) min(x) max(x)]);
grid on
subplot(2,1,2,'position',[0.3 0.2 0.6 0.3]);
plot(t,xx);
xlabel('时间');
ylabel('幅值');
axis([min(t) max(t) min(xx) max(xx)]);
grid on
set(handles.text1,'String','对原始信号和接受到信号进行比较');
% --- Executes on button press in compare2.
function compare2_Callback(hObject, eventdata, handles)
% hObject handle to compare2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)\
% compare between enPCM code and dePCM code
load data.mat;
subplot(2,1,1,'position',[0.3 0.57 0.6 0.3]);
plot(t8,y)
xlabel('时间');
ylabel('幅值');
axis([0 0.1 -1 2]);
grid on
subplot(2,1,2,'position',[0.3 0.2 0.6 0.3]);
plot(t8,yy);
xlabel('时间');
ylabel('幅值');
axis([0 0.1 -1 2]);
grid on
set(handles.text1,'String','对编码时的PCM码流和经过QAM系统后解调出的PCM码流进行比较');
% --- Executes on button press in Play_origin.
function Play_origin_Callback(hObject, eventdata, handles)
% hObject handle to Play_origin (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
load data.mat;
wavplay(x);
% --- Executes on button press in Play_arrive.
function Play_arrive_Callback(hObject, eventdata, handles)
% hObject handle to Play_arrive (see
colourpen
- 粉丝: 12
- 资源: 3
最新资源
- 基于activiti6和jeesite4的dreamFlow工作流管理设计源码
- 基于Python实现的简单植物大战僵尸脚本设计源码
- 基于Java及Web技术的医药管理系统设计源码
- 基于Objective-C的cordova-plugin-wechat插件开发源码研究
- 基于Python语言的SocialNetworkBackend社交数据分析系统后端设计源码
- 基于Python的pytracking-master目标跟踪dimp方法设计源码
- 基于PHP、JavaScript、CSS的zibll主题美化插件设计源码
- 毕业设计之mimo系统中中最大比合并和空时编码的性能研究
- 本程序对基于matlab对NOMA系统中经典多用户功率分配算法进行了研究
- Phone-1.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈