✅博主简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,Matlab项目合作可私信。
🍎个人主页:海神之光
🏆代码获取方式:
海神之光Matlab王者学习之路—代码获取方式
⛳️座右铭:行百里者,半于九十。
更多Matlab仿真内容点击👇
Matlab图像处理(进阶版)
路径规划(Matlab)
神经网络预测与分类(Matlab)
优化求解(Matlab)
语音处理(Matlab)
信号处理(Matlab)
车间调度(Matlab)
⛄一、PCM编码+QAM调制简介
1 PCM
数字信号是对连续变化的模拟信号进行抽样、量化和编码产生的,称为PCM(Pulse Code Modulation),即脉冲编码调制。
脉冲编码调制就是把一个时间连续,取值连续的模拟信号变换成时间离散,取值离散的数字信号后在信道中传输。脉冲编码调制就是对模拟信号先抽样,再对样值幅度量化,编码的过程。
抽样,就是对模拟信号进行周期性扫描,把时间上连续的信号变成时间上离散的信号。该模拟信号经过抽样后还应当包含原信号中所有信息,也就是说能无失真的恢复原模拟信号。它的抽样速率的下限是由抽样定理确定的。抽样速率采用8Kbit/s。
量化,就是把经过抽样得到的瞬时值将其幅度离散,即用一组规定的电平,把瞬时抽样值用最接近的电平值来表示。
一个模拟信号经过抽样量化后,得到已量化的脉冲幅度调制信号,它仅为有限个数值。编码,就是用一组二进制码组来表示每一个有固定电平的量化值。然而,实际上量化是在编码过程中同时完成的,故编码过程也称为模/数变换,可记作A/D。
话音信号先经防混叠低通滤波器,进行脉冲抽样,变成8KHz重复频率的抽样信号(即离散的脉冲调幅PAM信号),然后将幅度连续的PCM信号用“四舍五入”办法量化为有限个幅度取值的信号,再经编码后转换成二进制码。对于电话,CCITT规定抽样率为8KHz,每抽样值编8位码,即共有2^8=256个量化值,因而每话路PCM编码后的标准数码率是64kb/s。为解决均匀量化时小信号量化误差大,音质差的问题,在实际中采用不均匀选取量化间隔的非线性量化方法,即量化特性在小信号时分层密,量化间隔小,而在大信号时分层疏,量化间隔大。均匀量化的小信号的信噪比小。
非均匀量化: 由于一些信源信号, 如语音信号, 小幅度信号发生的概率大于大幅度信号的概率, 采用非均匀量化(即小幅度信号的量化步长小于大幅度信号的的量化步长) 效果更好好 (表现在语音信号上, 可以使信号具有足够的信噪比)。非均匀量化特性通常是把信号通过一个非线性的设备, 小信号幅度进行放大, 大信号幅度进行压缩, 再通过均匀量化实现。
2 常规双边带调幅AM
t 域:已调信号的波形,调制/解调方法
f 域:已调信号的频谱,带宽B
AM信号的包络正比于消息信号的规律,因此可以采用简单的**包络检波方法(非相干解调)**解调;
频谱由载波、上边带USB、下边带LSB组成。带宽BAM=2fH;
幅度调制又称为线性调制;
应用:中短波调幅广播。
缺点:功率利用率低,最多达到50%
⛄二、部分源代码
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 04-Jul-2021 19:27:45
% 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] = audioread(‘test.wav’);
t = (1:length(x))/fs;
t8 = length(x)8;
t8 = (1:t8)/fs;
Bs = 0.5fs;
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);%进行对应的频率转换
function qt = my_qammod(b)
[nrow,ncol]=size(b);
col=ncol/4;
b_2=reshape(b,4,col);
b_2=b_2’;
b_str2=int2str(b_2);
b_10=bin2dec(b_str2);
b_10=b_10’;
% — Executes on button press in Play_arrive.
%function Play_arrive_Callback(hObject, eventdata, handles)
% hObject handle to Play_arrive (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(xx);
% — Executes on button press in BYE.
function BYE_Callback(hObject, eventdata, handles)
% hObject handle to BYE (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
close
% --------------------------------------------------------------------
function About_Callback(hObject, eventdata, handles)
% hObject handle to About (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
msgbox({’ 本程序完成对简单音频信号的取样,’ 'PCM编码,QAM调制, 通过AWGN信道, ’ ‘QAM解调,PCM解码的一系列方针操作。’ ‘作者:吕非彼’ '电信工程学院 05114班 ’ ‘学号:050430 序号:12’},‘About’,‘Help’)
% — Executes during object creation, after setting all properties.
%function Play_origin_CreateFcn(hObject, eventdata, handles)
% hObject handle to Play_origin (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% — Executes during object deletion, before destroying properties.
%function Play_origin_DeleteFcn(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)
% — If Enable == ‘on’, executes on mouse press in 5 pixel border.
% — Otherwise, executes on mouse press in 5 pixel border or over Play_origin.
%function Play_origin_ButtonDownFcn(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)
⛄三、运行结果
⛄四、matlab版本及参考文献
1 matlab版本
2014a
2 参考文献
[1] 沈再阳.精通MATLAB信号处理[M].清华大学出版社,2015.
[2]高宝建,彭进业,王琳,潘建寿.信号与系统——使用MATLAB分析与实现[M].清华大学出版社,2020.
[3]王文光,魏少明,任欣.信号处理与系统分析的MATLAB实现[M].电子工业出版社,2018.
3 备注
简介此部分摘自互联网,仅供参考,若侵权,联系删除
🍅 仿真咨询
1 各类智能优化算法改进及应用
生产调度、经济调度、装配线调度、充电优化、车间调度、发车优化、水库调度、三维装箱、物流选址、货位优化、公交排班优化、充电桩布局优化、车间布局优化、集装箱船配载优化、水泵组合优化、解医疗资源分配优化、设施布局优化、可视域基站和无人机选址优化
2 机器学习和深度学习方面
卷积神经网络(CNN)、LSTM、支持向量机(SVM)、最小二乘支持向量机(LSSVM)、极限学习机(ELM)、核极限学习机(KELM)、BP、RBF、宽度学习、DBN、RF、RBF、DELM、XGBOOST、TCN实现风电预测、光伏预测、电池寿命预测、辐射源识别、交通流预测、负荷预测、股价预测、PM2.5浓度预测、电池健康状态预测、水体光学参数反演、NLOS信号识别、地铁停车精准预测、变压器故障诊断
3 图像处理方面
图像识别、图像分割、图像检测、图像隐藏、图像配准、图像拼接、图像融合、图像增强、图像压缩感知
4 路径规划方面
旅行商问题(TSP)、车辆路径问题(VRP、MVRP、CVRP、VRPTW等)、无人机三维路径规划、无人机协同、无人机编队、机器人路径规划、栅格地图路径规划、多式联运运输问题、车辆协同无人机路径规划、天线线性阵列分布优化、车间布局优化
5 无人机应用方面
无人机路径规划、无人机控制、无人机编队、无人机协同、无人机任务分配
6 无线传感器定位及布局方面
传感器部署优化、通信协议优化、路由优化、目标定位优化、Dv-Hop定位优化、Leach协议优化、WSN覆盖优化、组播优化、RSSI定位优化
7 信号处理方面
信号识别、信号加密、信号去噪、信号增强、雷达信号处理、信号水印嵌入提取、肌电信号、脑电信号、信号配时优化
8 电力系统方面
微电网优化、无功优化、配电网重构、储能配置
9 元胞自动机方面
交通流 人群疏散 病毒扩散 晶体生长
10 雷达方面
卡尔曼滤波跟踪、航迹关联、航迹融合