
公众号:matworld。 博主简介: 1.无线基带,无线图传,编解码 ; 2.机器视觉,图像处理,三维重建 ; 3.人工智能,深度学习 ; 4.智能控制,智能优化。 MATLAB/FPGA项目合作开发,项目源码请关注公众号
1.算法描述 随着射频设计者快速投入到支持长期演进( LTE )手机无线标准的新产品的开发过程中,理解LTE的测试需求变得更加重要,因为该技术已经越来越普遍。本文介绍了LTE的概念以及测试工程师面临的挑战。 LTE是3GPP手机网络定义的下一代无线网络技术,允许运营商越过其他已有的无线接入技术提供同样的应用和服务,能实现非常高的数据率,为终端用户提供显著提升的用户体验。基于LTE的网络和基于正交频分复用(OFDM)并采用多输入多输出(MIMO)的传输方式,有时也称之为4G。 测试挑战 LTE测试有两个主要的挑战:从单载波到多载波的OFDM调制信号以及从SISO(单输入单输出)到MIMO的信号传输流。 OFDM信号有多个子载波,互相之间精确排列并占用较宽的带宽(达到20MHz),较大多数射频工程师熟悉的传统单载波信号更加复杂。从各个方面测量这些信号对于确认无线电通信的正确工作并在出问题时快速诊断出问题所在区域非常重要。例如,测量在整个频道内每个子载波的调制质量,即EVM(误差向量幅度)测量,可探测出放大器、滤波器、频率响应波形,或窄带干扰问题。简单地说,在覆盖整个传输帧的整个时间段内测量EVM分量,可探测出由放大器热效应、失效以及开关或频率引起的问题。 OFDM信号较单载波信号具有更高的峰值-均值比(PAR),这增加了发送级功率放大器增益压缩引起误码的可能性。与WiMAX不同,LTE在移动设备中使用不同的调制方法(SC-FDMA)来进行补偿。但这增加了放大器的功率消耗,使基带处理变得更加复杂并最终造成更多功耗。基于深度学习的方法,而不需要插入导频,直接进行检测。 深度学习(英语:deep learning),是一个多层神经网络是一种机器学习方法。在深度学习出现之前,由于诸如局部最优解和梯度消失之类的技术问题,没有对具有四层或更多层的深度神经网络进行充分的训练,并且其性能也不佳。但是,近年来,Hinton等人通过研究多层神经网络,提高学习所需的计算机功能以及通过Web的开发促进培训数据的采购,使充分学习成为可能。结果,它显示出高性能,压倒了其他方法,解决了与语音,图像和自然语言有关的问题,并在2010年代流行。 深度学习(DL, Deep Learning)是机器学习(ML, Machine Learning)领域中一个新的研究方向,它被引入机器学习使其更接近于最初的目标——人工智能(AI, Artificial Intelligence)。 深度学习是学习样本数据的内在规律和表示层次,这些学习过程中获得的信息对诸如文字,图像和声音等数据的解释有很大的帮助。它的最终目标是让机器能够像人一样具有分析学习能力,能够识别文字、图像和声音等数据。 深度学习是一个复杂的机器学习算法,在语音和图像识别方面取得的效果,远远超过先前相关技术。 深度学习在搜索技术,数据挖掘,机器学习,机器翻译,自然语言处理,多媒体学习,语音,推荐和个性化技术,以及其他相关领域都取得了很多成果。深度学习使机器模仿视听和思考等人类的活动,解决了很多复杂的模式识别难题,使得人工智能相关技术取得了很大进步。 深度学习是机器学习的一种,而机器学习是实现人工智能的必经路径。深度学习的概念源于人工神经网络的研究,含多个隐藏层的多层感知器就是一种深度学习结构。深度学习通过组合低层特征形成更加抽象的高层表示属性类别或特征,以发现数据的分布式特征表示。研究深度学习的动机在于建立模拟人脑进行分析学习的神经网络,它模仿人脑的机制来解释数据,例如图像,声音和文本等。 2.仿真效果预览matlab2022a仿真结果如下:3.MATLAB核心程序numTrainFiles = 100;%设置每个类别的训练个数 [imdsTrain, imdsValidation] = splitEachLabel(imds, numTrainFiles, 'randomize'); %定义卷积神经网络的基础结构 layers = [ imageInputLayer([128 14 3]);%注意,400,150为能量图的大小,不能改 %第一个卷积层 convolution2dLayer(3, 8, 'Padding', 'same');%第一个卷积层 batchNormalizationLayer; reluLayer; maxPooling2dLayer(2, 'Stride', 2); %第二个卷积层 convolution2dLayer(3, 16, 'padding', 'same'); batchNormalizationLayer; reluLayer; maxPooling2dLayer(2, 'Stride', 2); %第3个卷积层 convolution2dLayer(3, 16, 'padding', 'same'); batchNormalizationLayer; reluLayer; maxPooling2dLayer(2, 'Stride', 2); %第4个卷积层 convolution2dLayer(3, 16, 'padding', 'same'); batchNormalizationLayer; reluLayer; %全连接层1 fullyConnectedLayer(2); %全连接层2 fullyConnectedLayer(2); %softmax softmaxLayer; %输出分类结果 classificationLayer;]; %设置训练参数 options = trainingOptions('adam', ... 'InitialLearnRate', 0.0005, ... 'MaxEpochs', 500, ... 'Shuffle', 'every-epoch', ... 'ValidationData', imdsValidation, ... 'ValidationFrequency', 10, ... 'Verbose', false, ... 'Plots', 'training-progress'); %使用训练集训练网络 net = trainNetwork(imdsTrain, layers, options); %对验证图像进行分类并计算精度 YPred = classify(net, imdsValidation); YValidation = imdsValidation.Labels; accuracy = 100*sum(YPred == YValidation) / numel(YValidation)
1.算法描述 在一些应用领域数据可以自然而然地表示成图结构,包括 蛋白质组学,图像分析,场景描述 ,软件工程,和自然语言处理。最简单的图结构包括单一节点和序列。但在一些应用中,信息组织在一些更为复杂的图结构中,比如树,非循环图或循环图中,数据关系开采 已经成为归纳逻辑设计工作室许多研究的主题,并且近年来这项研究主题已经深化到诸多不同领域,当然这和数理统计和神经网络的相关概念在这些领域的应用密不可分。 在机器学习中,结构化数据和通过对样本(有监督或无监督的)学习的目标有关,通过一个将图像G映射到实数矢量的函数。 在这篇论文中,图像领域的应用大致可以区分为两大类:聚焦线和聚焦节点的应用。在聚焦连线的应用中,该函数不依赖节点并将一个分类或回归量运用于图结构数据集。比如,一个化合物可以用图建立模型,其中那些节点表示原子,边表示将原子联系起来的化学键[见图.1(a)]。这种映射可以用于估计该化合物造成某种疾病的概率。在图.1(b),一张图片由区域邻接的图表示,其中节点表示强度上具有同性质的区域,弧线表示他们的邻接关系。在这个例子中,被用于对图片归类,根据图中城堡,车,人等内容。 在聚焦节点的应用中,依赖节点,以此其分类或统计回归依赖于每个节点的固有关系。目标侦查是这类应用的一个例子。找出一张图片是否包含了被搜寻目标,并且如果有,标示其位置。这个问题可以由一个函数解决,它能将邻接区域图的节点分类,根据对应区域是否符合目标。比如,图1.(b)的输出可能是1标示契合城堡的黑色节点,并且其他的用0表示。另一个例子来自网络。网站可以由图表示,节点表示网页,边表示之间的超链接[图.1(c)]。网站连通性可以被利用,通过网页内容,来达到一些目的,比如将网页划分为一组主题。 传统机器学习的应用通过使用一个预处理阶段处理图结构数据,这一阶段将图结构信息映射为一个简单的表述,比如实数向量。换句话说,预处理步骤将图结构“压扁”成实数向量,之后通过基于列表的数据处理技术处理预加工数据。然而,重要信息,比如每个节点的拓扑从属信息可能会在预处理阶段损失并最终结果会以不可预测的方法取决于预处理算法的细节。更近年来,有各种方法,尝试保留数据的图结构属性。这种思路想将存在潜在图结构的数据编码,通过使用图中节点的拓扑关系,借此将图结构信息包含在数据处理阶段。 GNNs是基于信息扩散机理。一个图被处理为一系列单元,每个相当于图的节点,他们根据图的连通性联结着。这些单元刷新它们的状态并交换信息直到它们达到稳定平衡。之后基于单元的状态,GNN的输出可以在节点层间计算出。扩散机理的限制使得一个独特的稳定平衡总是存在。这种认识机制已被用在蜂窝神经网络及Hopfield神经网络。在这些神经网络模型中,连通性根据预定义的图描述,网络的连接自然属性上是循环周期性的,神经元的状态通过达到一个平衡点来计算。GNNs有别于蜂窝神经网络及Hopfield神经网络在于它们可以用在处理更广泛类型的图,如无向图,并且它们采用更综合的扩散机制。 GNN神经网络,整个训练的算法流程我们按如下的步骤进行:2.仿真效果预览matlab2022a仿真结果如下:3.MATLAB核心程序Index = 0; for nn = 1:length(Nodes) Nodes(nn) tic; Index = Index + 1; %初始参数 %学习率 Learn_rate = 0.2; %惯性 lemda = 0.01; %网络结构参数 Num_I = 40; Num_Hide = 120; Num_O = 1; %训练次数 Train_Time = 40; %初始化神经元输入信号 dw = cell(1,Num_I); delta = [zeros(1,Num_Hide)]; x = [zeros(1,Num_I)]; Yout = 0; du = 0; Yout_Delay = zeros(1,Num_I); l = zeros(1,Num_I); %隐藏层神经元的输出 Oh = zeros(Num_Hide,1); I = Oh; Oh_delay = Oh; %初始化突触权值参数 Net = func_initialize(Num_I,Num_Hide,Num_O); %forward x = func_forward(Net,l); k = 0; while(k <= Train_Time | k <= Nodes(nn)) k = k + 1; %模拟训练数据和训练目标 P(k) = 1; Yout(k) = (0.5*Yout_Delay(1)+P(k))/(1 + Yout_Delay(1)^2); [Yout_Est(k),I,Oh] = func_backward(x,Net,Oh_delay,Num_Hide); Err(k) = Yout(k) - Yout_Est(k); %Jacobian Jacobian_out(k) = func_Jacobian(Net,delta,Num_Hide); %更新网络系数w [Net,dw,delta] = func_w_update(x,I,Net,dw,Err(k),Learn_rate,lemda,Oh,Oh_delay,Num_I,Num_Hide); %FORWARD l = [Err(k),Yout(k),Yout_Delay(1:end-2)]; x = func_forward(Net,l); %Delay; Yout_Delay(1) = Yout(k); for idx = 2:Num_I Yout_Delay(idx)=Yout_Delay(idx-1); end Net.wd2{1} = Net.wd1{1}; Net.wd1{1} = Net.w{1}; Net.wd2{3} = Net.wd1{3}; Net.wd1{3} = Net.w{3}; Net.wd2{2} = Net.wd1{2}; Net.wd1{2} = Net.w{2}; end toc; time(Index) = toc; end
1.算法描述 假设有M个用户均为MIMO Full Duplex,N个频率,1<N<M,设计算法实现M个用户与N个频率的匹配。 由于在一个MIMO系统中,用户数量M大于可用的频谱个数N,因此,必有一部分用户存在频谱共享的问题。目前,现有的关于频谱分配的方法主要有基于竞价的分配方法,基于博弈论的分配方法,现有资料,主要都是这两种方法。下面针对这个问题,提出如下的改进方案: 这个改进方案,命名为基于改进遗传优化算法的多因素加权竞价博弈频谱分配算法。 这里,有别于传统的频谱分配方法,这里的分配方法,考虑了多种因素,我们分别假设为y1,y2,y3,。。。。。yn,并通过遗传优化算法,计算一种分配方案,即M个用户分配到N个频谱上, 分别计算以不同因素进行划分所得到的效益值V1,V2,V3,。。。。。Vn,,最后将这将这n个因素进行加权,得到其综合效益值: 根据遗传优化算法流程可知,其详细步骤如下所示: 步骤一:选择问题解的一个编码,给出一个有N个染色体的初始群体。编码的主要功能为确定用何种码制,然后将问题参数编码形成基因码链,每一个码链代表一个个体,表示优化问题的一个解。 根据编码方式不同可以分为二进制编码和实数编码两种类型,其中二进制编码的优势在于编码方式简单,便于遗传算法的交叉和编码操作。 步骤二:对群体中的每一个染色体,计算它的适应函数值。适应函数值为群体进化时的选择提供了依据,一般来说适应度越高,解的素质越好。适应度函数可以根据目标函数而定。 步骤三:若停止规则满足,则算法停止,否则计算概率P,并以此概率分布,从旧的种群pop(t)中随机选取N个染色体构成一个新的种群。选择操作常见的操作方式有比例 选择和排序选择方式。 步骤四:通过交叉,得到N个染色体的交叉集合。交叉的主要功能从种群中随机选择两个染色体,按一定的概率进行基因交换,交换位置的选取是随机的。 竞价和博弈相结合的联合分配方法; 值最大的用户,有先分配频谱资源,值最小的,则根据实际频谱资源情况,进行共用某一相同的频谱资源。 2.仿真效果预览matlab2022a仿真结果如下:3.MATLAB核心程序clear; close all; warning off; addpath(genpath(pwd)); K=20; %用户对数 N=2; %收发天线数 INR_dB=5;INR=db2pow(5); eta=INR/N; %用户对间的干扰 SI=db2pow(20); %自干扰 u=1; %weighted k = db2pow(-40); beta = db2pow(-40); times=5; SNR_dB= -10:10:50; rho_real=db2pow(SNR_dB)/N; sum_rate_HD=zeros(1,length(rho_real)); sum_rate_FD=zeros(1,length(rho_real)); sum_rate_HD_TDMA=zeros(1,length(rho_real)); sum_rate_FD_TDD=zeros(1,length(rho_real)); for tt=1:times tt %通信信道 H_cha= rayleigh( N,N,2*K); %自干扰信道 H_sel= rayleigh( N,N,2*K); %用户间干扰信道 H_int= rayleigh( N,N,8*K); Rate_HD=zeros(1,length(rho_real)); Rate_HD_TDMA=zeros(1,length(rho_real)); Rate_FD=zeros(1,length(rho_real)); Rate_FD_TDD=zeros(1,length(rho_real)); i=1; for rho=rho_real % rho V=right_singular(H_cha,2*K); [ Rate_HD_get ] = HD_MIMO_interference(N,H_int,H_cha,H_sel,V,rho,eta,beta,k,u ,K); Rate_HD(i)=Rate_HD_get; [ Rate_FD_get ] = FD_MIMO_interference(N,H_int,H_cha,H_sel,V,rho,eta,SI,beta,k,u ,K); Rate_FD(i)=Rate_FD_get; i=i+1; end sum_rate_HD=sum_rate_HD+Rate_HD; sum_rate_FD=sum_rate_FD+Rate_FD; end sum_rate_HD=real(sum_rate_HD/times/2); sum_rate_FD=real(sum_rate_FD/times); figure; semilogy(SNR_dB,sum_rate_FD,'b-^','linewidth',2); hold on semilogy(SNR_dB,sum_rate_HD,'b-s','linewidth',2); grid on; xlabel('SNR (dB)') ylabel('sum Rate (b/s/HZ)') legend('FD','HD') 01-140m
1.算法描述 一个可以活动的小车上立着一根不稳定随时会倒下的杆。小车的轮子由电机控制,可以控制小车电机的转动力矩M。同时,也可以获取小车轮子转动的圈数N(可以精确到小数)和杆相对于垂直位置的倾角α. 不考虑车轮打滑, 小车所受力大小等于电机力矩乘车轮半径, 小车位置可以从转动圈数计算出, 小车可简化为最经典的一阶倒立摆: 对小车水平方向:Mx¨+bx˙+N=F对摆水平方向:N=md2dt(x+lsinθ)即:N=mx¨+mlθ¨cosθ¨−mlθ˙2sinθ对摆垂直方向:P=mg+md2dt(lcosθ)即:P=mg−mlθ¨sinθ¨−mlθ˙2cosθ关节力矩:−Plsinθ−Nlcosθ=Iθ¨令 ϕ=π+θ在工作点 θ≈0 进行线性化: sinθ=0,cosθ=1,θ˙2=0 经过一顿操作化简之后能得到:(I+ml2)ϕ¨−mglϕ=mlx¨ (M+m)x¨+bx˙−mlϕ¨=F=u2.仿真效果预览matlab2022a仿真如下:3.MATLAB核心程序% PENDULUM M-file for pendulum.fig % PENDULUM, by itself, creates a new PENDULUM or raises the existing % singleton*. % % H = PENDULUM returns the handle to a new PENDULUM or the handle to % the existing singleton*. % % PENDULUM('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in PENDULUM.M with the given input arguments. % % PENDULUM('Property','Value',...) creates a new PENDULUM or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before pendulum_OpeningFunction gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to pendulum_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 pendulum % Last Modified by SHE on 15-Dec-2008 22:08:58 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @pendulum_OpeningFcn, ... 'gui_OutputFcn', @pendulum_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 pendulum is made visible. function pendulum_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 pendulum (see VARARGIN) % Choose default command line output for pendulum handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes pendulum wait for user response (see UIRESUME) % uiwait(handles.figure1); % --- Outputs from this function are returned to the command line. function varargout = pendulum_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; function edit1_Callback(hObject, eventdata, handles) % hObject handle to edit1 (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 edit1 as text % str2double(get(hObject,'String')) returns contents of edit1 as a double %以字符串的形式来存储数据文本框1的内容。如果字符串不是数字,则现实空白内容 input =str2double(get(hObject,'String')); %检查输入是否为空. 如果为空,则默认显示为0 if (isempty(input)) set(hObject,'String','0') end guidata(hObject, handles); % --- Executes during object creation, after setting all properties. function edit1_CreateFcn(hObject, eventdata, handles) % hObject handle to edit1 (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 set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end function edit2_Callback(hObject, eventdata, handles) % hObject handle to edit2 (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 edit2 as text % str2double(get(hObject,'String')) returns contents of edit2 as a double %以字符串的形式来存储数据文本框2的内容。如果字符串不是数字,则现实空白内容 input =str2double(get(hObject,'String')); %检查输入是否为空. 如果为空,则默认显示为0 if (isempty(input)) set(hObject,'String','0') end guidata(hObject, handles); % --- Executes during object creation, after setting all properties. function edit2_CreateFcn(hObject, eventdata, handles) % hObject handle to edit2 (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 set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end function edit3_Callback(hObject, eventdata, handles) % hObject handle to edit3 (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 edit3 as text % str2double(get(hObject,'String')) returns contents of edit3 as a double %以字符串的形式来存储数据文本框3的内容。如果字符串不是数字,则现实空白内容 input =str2double(get(hObject,'String')); %检查输入是否为空. 如果为空,则默认显示为0 if (isempty(input)) set(hObject,'String','0') end guidata(hObject, handles); % --- Executes during object creation, after setting all properties. function edit3_CreateFcn(hObject, eventdata, handles) % hObject handle to edit3 (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 set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end function edit4_Callback(hObject, eventdata, handles) % hObject handle to edit4 (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 edit4 as text % str2double(get(hObject,'String')) returns contents of edit4 as a double %以字符串的形式来存储数据文本框4的内容。如果字符串不是数字,则现实空白内容 input =str2double(get(hObject,'String')); %检查输入是否为空. 如果为空,则默认显示为0 if (isempty(input)) set(hObject,'String','0') end guidata(hObject, handles); % --- Executes during object creation, after setting all properties. function edit4_CreateFcn(hObject, eventdata, handles) % hObject handle to edit4 (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 set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end function edit5_Callback(hObject, eventdata, handles) % hObject handle to edit5 (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 edit5 as text % str2double(get(hObject,'String')) returns contents of edit5 as a double %以字符串的形式来存储数据文本框5的内容。如果字符串不是数字,则现实空白内容 input =str2double(get(hObject,'String')); %检查输入是否为空. 如果为空,则默认显示为0 if (isempty(input)) set(hObject,'String','0') end guidata(hObject, handles); % --- Executes during object creation, after setting all properties. function edit5_CreateFcn(hObject, eventdata, handles) % hObject handle to edit5 (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 set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end % --- Executes on selection change in popupmenu1. function popupmenu1_Callback(hObject, eventdata, handles) % hObject handle to popupmenu1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: contents = get(hObject,'String') returns popupmenu1 contents as cell array % contents{get(hObject,'Value')} returns selected item from popupmenu1 popup_sel_index = get(handles.popupmenu1, 'Value'); popup_sel_index = get(handles.popupmenu1, 'Value'); switch popup_sel_index case 1 set(handles.text10 ,'String','期望极点'); set(handles.text11 ,'String',' -10 -10'); set(handles.text12 ,'String','-2+2*sqrt(3)*i -2-2*sqrt(3)*i'); case 2 set(handles.text10 ,'String','加权矩阵'); set(handles.text11 ,'String','Q=[1 0 0 0; 0 0 0 0; 0 0 1 0;0 0 0 0];'); set(handles.text12 ,'String',' R=1'); case 3 set(handles.text10 ,'String','参考输入'); set(handles.text11 ,'String',' y_r=0.2*U(t)'); set(handles.text12 ,'String',' '); case 4 set(handles.text10 ,'String','PID'); set(handles.text11 ,'String',' P=5,I=0.001,D=1'); set(handles.text12 ,'String',' '); end % --- Executes during object creation, after setting all properties. function popupmenu1_CreateFcn(hObject, eventdata, handles) % hObject handle to popupmenu1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: popupmenu controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end % --- Executes on button press in pushbutton1. function pushbutton1_Callback(hObject, eventdata, handles) % hObject handle to pushbutton1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) warning off M = str2double(get(handles.edit1, 'String'));%小车质量 m = str2double(get(handles.edit2, 'String'));%摆杆质量 b = str2double(get(handles.edit3, 'String'));%小车阻尼 I = str2double(get(handles.edit4, 'String'));%摆杆转动惯量 l = str2double(get(handles.edit5, 'String'));%摆杆长度 g=9.8; %重力加速度 %%%%%%%%%%%%%%%%%%%%%%%%计算系统状态矩阵%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% A=[ 0 1 0 0;... (M+m)*m*g*l/((M+m)*I+M*m*l^2) 0 0 m*l*b/((M+m)*I+M*m*l^2);... 0 0 0 1;... -m^2*l^2*g/((M+m)*I+M*m*l^2) 0 0 -(I+m*l^2)*b/((M+m)*I+M*m*l^2)]; B=[0;-m*l/(((M+m)*I+M*m*l^2));0;(I+m*l^2)/((M+m)*I+M*m*l^2)]; C=[0 0 1 0;1 0 0 0]; D=zeros(2,1); E=zeros(4,1); %%%%%%%%%%%%%%%%%%%%将状态矩阵转存到状态空间%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% assignin('base','A',A); assignin('base','B',B); assignin('base','C',C); assignin('base','D',D); assignin('base','E',E); %%%%%%%%%%%%%%%%%%%%%%选择倒立摆的控制方式%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% popup_sel_index = get(handles.popupmenu1, 'Value'); switch popup_sel_index case 1 %%极点配置法 Qc=ctrb(A,B); EA=[-10 0 0 0;... 0 -10 0 0;... 0 0 -2-2*sqrt(3)*i 0;... 0 0 0 -2+2*sqrt(3)*i]; PP=polyvalm(poly(EA),A); Ks=[0 0 0 1]*inv(Qc)*PP; %%计算反馈矩阵 [t,x,y]=sim('jwgcqp.mdl'); %%调用降维观测器的simulink模块 axes(handles.axes1); plot(t,y(:,1)); axes(handles.axes2); plot(t,y(:,3)); axes(handles.axes3) plot([-0.02;0.02],[-0.8;-0.8],'color','k','linestyle','-','linewidth',2); axis([-0.02 0.02 -1.2 1.2]); car1=line([-0.004;0.004],[-0.5;-0.5],'color','k','linestyle','-','erasemode','xor','linewidth',25); car21=line(-0.004,-0.72,'color','k','linestyle','-','erasemode','xor','markersize',40); car22=line( 0.004,-0.72,'color','k','linestyle','-','erasemode','xor','markersize',40); pendulum1=line([0;0],[-0.3;0.6],'color','r','linestyle','-','erasemode','xor','linewidth',10); pendulum2=line(0,-0.27,'color','g','linestyle','-','erasemode','xor','markersize',30); for s=1:length(t) set(car21,'xdata',-0.004+y(s,3),'ydata',-0.72); set(car22,'xdata', 0.004+y(s,3),'ydata',-0.72); set(car1,'xdata',[-0.004+y(s,3);0.004+y(s,3)],'ydata',[-0.5;-0.5]); set(pendulum2,'xdata',y(s,3),'ydata',-0.27); set(pendulum1,'xdata',[y(s,3);sin(y(s,1))+y(s,3)],'ydata',[-0.3;-0.3+cos(y(s,1))]); drawnow; end case 2 %%LQR最优控制器 QQ=diag([1,0,1,0]); RR=1; Ks=lqr(A,B,QQ,RR); %%计算反馈矩阵 [t,x,y]=sim('jwgcql.mdl'); %%调用降维观测器的simulink模块 % figure(2) % subplot(4,2,1) % plot(t,y(:,1)) % title('系统状态变化') % subplot(4,2,2) % plot(t,y(:,5)) % title('降维观测器结果') % subplot(4,2,3) % plot(t,y(:,2)) % subplot(4,2,4) % plot(t,y(:,6)) % subplot(4,2,5) % plot(t,y(:,3)) % subplot(4,2,6) % plot(t,y(:,7)) % subplot(4,2,7) % plot(t,y(:,4)) % subplot(4,2,8) % plot(t,y(:,8)) axes(handles.axes1); plot(t,y(:,1)); axes(handles.axes2); plot(t,y(:,3)); axes(handles.axes3); plot([-0.3;0.3],[-0.8;-0.8],'color','k','linestyle','-','linewidth',2); axis([-0.3 0.3 -1.2 1.2]); car1=line([-0.06;0.06],[-0.5;-0.5],'color','k','linestyle','-','erasemode','xor','linewidth',25); car21=line(-0.06,-0.72,'color','k','linestyle','-','erasemode','xor','markersize',40); car22=line( 0.06,-0.72,'color','k','linestyle','-','erasemode','xor','markersize',40); pendulum1=line([0;0],[-0.3;0.6],'color','r','linestyle','-','erasemode','xor','linewidth',10); pendulum2=line(0,-0.27,'color','g','linestyle','-','erasemode','xor','markersize',30); for s=1:length(t) set(car21,'xdata',-0.06+y(s,3),'ydata',-0.72); set(car22,'xdata', 0.06+y(s,3),'ydata',-0.72); set(car1,'xdata',[-0.06+y(s,3);0.06+y(s,3)],'ydata',[-0.5;-0.5]); set(pendulum2,'xdata',y(s,3),'ydata',-0.27); set(pendulum1,'xdata',[y(s,3);sin(y(s,1))+y(s,3)],'ydata',[-0.3;-0.3+cos(y(s,1))]); drawnow; end case 3 % A=[ 0 1 0 0;... % (M+m)*m*g*l/((M+m)*I+M*m*l^2) 0 0 m*l*b/((M+m)*I+M*m*l^2);... % 0 0 0 1;... % -m^2*l^2*g/((M+m)*I+M*m*l^2) 0 0 -(I+m*l^2)*b/((M+m)*I+M*m*l^2)]; % B=[0;-m*l/(((M+m)*I+M*m*l^2));0;(I+m*l^2)/((M+m)*I+M*m*l^2)]; % C=[0 0 1 0;1 0 0 0]; % p=[-10,-7,-1.901,-1.9]; % Kysw=place(A,B,p); [x,y]=sim('pedulumpid.mdl'); axes(handles.axes1); plot(t,y(:,1)); axes(handles.axes2); plot(t,y(:,3)); axes(handles.axes3); plot([-0.3;0.3],[-0.8;-0.8],'color','k','linestyle','-','linewidth',2); axis([-0.3 0.3 -1.2 1.2]); car1=line([-0.06;0.06],[-0.5;-0.5],'color','k','linestyle','-','erasemode','xor','linewidth',25); car21=line(-0.06,-0.72,'color','k','linestyle','-','erasemode','xor','markersize',40); car22=line( 0.06,-0.72,'color','k','linestyle','-','erasemode','xor','markersize',40); pendulum1=line([0;0],[-0.3;0.6],'color','r','linestyle','-','erasemode','xor','linewidth',10); pendulum2=line(0,-0.27,'color','g','linestyle','-','erasemode','xor','markersize',30); for s=1:length(t) set(car21,'xdata',-0.06+y(s,3),'ydata',-0.72); set(car22,'xdata', 0.06+y(s,3),'ydata',-0.72); set(car1,'xdata',[-0.06+y(s,3);0.06+y(s,3)],'ydata',[-0.5;-0.5]); set(pendulum2,'xdata',y(s,3),'ydata',-0.27); set(pendulum1,'xdata',[y(s,3);sin(y(s,1))+y(s,3)],'ydata',[-0.3;-0.3+cos(y(s,1))]); drawnow; end end % --- Executes on button press in pushbutton4. function pushbutton4_Callback(hObject, eventdata, handles) % hObject handle to pushbutton4 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) pause; % --- Executes on button press in pushbutton5. function pushbutton5_Callback(hObject, eventdata, handles) % hObject handle to pushbutton5 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) close(gcbf); clc,clear,close all A87
1.算法描述 将遗传算法(GA)与BP神经网络相结合,使用GA优化BP神经网络的主要参数。然后将影响输出响应值的多个特征因素作为GA-BP神经网络模型的输入神经元, 输出响应值作为输出神经元进行预测测试。BP神经网络的网络层包括输入层,隐含层和输出层三个网络层次,其基本结构如下图所示: 基于三层网络结构的BP神经网络具有较为广泛的应用场合和训练效果。 在BP神经网络中,隐含层数量对神经网络的性能有着至关重要的影响,如果隐含层数量过多,会大大增加BP神经网络的内部结构的复杂度,从而降低学习效率,增加训练时间;如果隐含层数量过少,则无法精确获得训练输入数据和输出结果之间的内在规律,增加预测误差。因此,选择合适的隐含层个数具有十分重要的意义。由于隐含层个数的设置没有明确的理论可以计算,通常情况下,采用逐次分析的方法获得,即通过对不同隐含层所对应的神经网络进行预测误差的仿真分析,选择误差最小情况下所对应的隐含层个数。 学习率,即网络权值得更新速度,当学习率较大的时候,网络权值的更新速度快,当网络稳定性会下降;当学习率较小的时候,网络权值的更新速度慢,网络较为稳定。这里选择BP神经网络的学习率方式参考上一章节隐含层的选择方式,即通过对比不同学习率的网络训练误差,选择性能较优的学习率。 BP神经网络的初始网络权值对网络训练的效率以及预测性能有着较大的影响,通常情况下,采用随机生成[-1,1]之间的随机数作为BP神经网络的初始权值。 本文,通过matlab的BP神经网络工具箱函数newff来构建BP神经网络,通过newff函数构建BP网络,其主要步骤如下: 第一,BP神经网络初始化后,其matlab程序如下: net = newff(traindata, trainaim, HiddenNum); 其中traindata表示训练数据,trainaim表示训练目标,HiddenNum表示BP神经网络隐含层个数,net表示BP神经网络模型函数。 第二,BP神经网络参数设置,其matlab程序所示: 设置学习率,其matlab程序为 net.trainParam.lr = 0.25;设置训练误差目标,其matlab程序为net.trainParam.goal = 1e-8;设置神经网络训练次数,其matlab程序为net.trainParam.epochs = 200; 第三,BP神经网络的训练,其matlab程序所示: net = train(net,train_data,train_aim); 这里通过train函数对神经网络net进行训练,得到训练后的BP神经网络模型。其算法流程图如图2所示: 从图2的算法流程图可知,基于自适应遗传优化的BP神经网络模型其主要通过交叉概率与变异概率的自适应调节,使个体对网络权值进行不断的更新,从而提高BP神经网络的预测精度。通过MATLAB对BP神经网络,基于遗传优化的BP神经网络,基于改进遗传优化的BP神经网络以及基于改进遗传优化的组合BP神经网络等多种算法的股价预测性能。从仿真结果可知,基于改进遗传优化的组合BP神经网络性能略优于改进遗传优化的BP神经网络,而比起传统的BP神经网络预测算法和基于传统遗传优化的BP神经网络预测算法,具有较大的性能优势。 2.仿真效果预览matlab2022a仿真结果如下:3.MATLAB核心程序Mins = min(C); Maxs = max(C); C = (C-Mins)/(Maxs-Mins); LEN = 10; %样本的划分 for i = 1:length(C)-LEN Price1(:,i) = C(i:i+LEN-1); Price2(i) = C(i+LEN); end %训练样本 L1 = floor(0.6*length(Price2)); for i = 1:L1 train_data(:,i) = Price1(:,i); train_aim(i) = Price2(i); end %测试样本 L2 = length(Price2) - L1; for i = 1:L2 test_data(:,i) = Price1(:,i+L1); test_aim(i) = Price2(i+L1); end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %如下的是改进BP网络算法 %定义神经网络的各个层的个数 Num_In = LEN; Num_Hidden = 5; Num_Out = 1; %构建BP网络 net = newff(train_data,train_aim,Num_Hidden); ERR1 = []; ERR2 = []; ERR3 = []; %通过改进遗传算法优化BP参数 net = func_newGA2(net,Num_In,Num_Hidden,Num_Out,train_data,train_aim); %网络训练 net.trainParam.showWindow = 0; net = train(net,train_data,train_aim); outputs = sim(net,test_data); d1 = test_aim*(Maxs-Mins) + Mins; d2 = outputs*(Maxs-Mins) + Mins; ERR1 = [ERR1,mean(abs(d1-d2)./d2) ]; ERR2 = [ERR2,mean((abs(d1-d2)./d2).^2) ]; ERR3 = [ERR3,std((abs(d1-d2)./d2).^2) ]; 02_034m
1.算法概述 MATLAB系统供了许多工具箱(Toolbox),借助于信号处理工具箱(signal processing)中的freqz_m,remez等函数,使得FIR数字滤波器的设计大为简化,每个程序都只有短短的几十行。因此实用MATLAB进行滤波器的设计变得十分简便。本文分析了国内外数字滤波技术的应用现状与发展趋势,介绍了数字滤波器的基本结构,数字滤波器根据其冲激响应函数的时域特性,可分为两种,即无限长冲激响应(IIR)滤波器和有限长冲激响应(FIR)滤波器。讨论了IIR与FIR数字滤波器的设计方法。本文利用matlab的强大计算功能和信号数据处理功能,本文用matlab设计的数字滤波器对信号进行滤波降噪处理,并对实验方法的改进展开了讨论。 ·有限冲击响应(Finite Impulse Response,FIR)滤波器 有限长冲击响应滤波器,即FIR滤波器,是指离散系统的单位冲击响应h(k)是一个有限长的序列,即系统的单位冲击响应只在给定的时间区间里有非零值。FIR滤波器的单位抽样响应为有限长度,一般采用非递归形式实现。通常的FIR数字滤波器有横截性和级联型两种。 无限冲击响应滤波器,即IIR滤波器,是指离散系统的单位冲击响应h(k)是一个无限长的时间序列。这种滤波器滤波的实现结构与一般数字滤波器的结构相同。一个数字滤波器可以用系统函数表示为: 可见数字滤波器的功能就是把输入序列x(n)通过一定的运算变换成输出序列y(n)。不同的运算处理方法决定了滤波器实现结构的不同。无限冲激响应滤波器的单位抽样响应h(n)是无限长的,其差分方程如(2-2)式所示,是递归式的,即结构上存在着输出信号到输入信号的反馈,其系统函数具有(2-1)式的形式,因此在z平面的有限区间(0<︱z︱<∞)有极点存在。 2.仿真效果预览matlab2022a仿真3.MATLAB部分代码预览%k=input('请选择窗的类型:\n 1、矩形窗\n 2、汉宁窗\n 3、汉明窗\n 4、布拉克曼窗\n'); k=2 switch k case 1 x=win(0,N-1,0,N-1); %矩形窗 figure, subplot(1,2,1); stem(n,x,'.'); %得到数字信号波形表示方法函数STEM xlabel('n'); %X坐标标签 ylabel('x'); %Y坐标标签 string=['矩形窗时域图形','N=',num2str(N)];%波形标题 text((0.6*N),0.8,string); %波形标题 [H,m]=freqz(x,[1],1024,'whole'); %求其频率响应 mag=abs(H); %得到幅值 db=20*log10((mag+eps)/max(mag)); subplot(1,2,2); plot(m/pi,db); xlabel('w/pi'); ylabel('dB'); title('矩形窗的频率特性(db)'); axis([0,1,-100,0]); string=['矩形窗','N=',num2str(N)]; %================================================================== case 2 x=win(0,N-1,0,N-1); x=(0.5-0.5*cos(2*pi*n/(N-1))).*x; figure, subplot(1,2,1); stem(n,x,'.'); xlabel('n'); ylabel('x'); string=['汉宁窗时域图形','N=',num2str(N)]; text((0.6*N),0.8,string); [H,m]=freqz(x,[1],1024,'whole'); %求其频率响应 mag=abs(H); %得到幅值 db=20*log10((mag+eps)/max(mag)); subplot(1,2,2); plot(m/pi,db); xlabel('w/pi'); ylabel('dB'); title('汉宁窗的频率特性(db)'); axis([0,1,-100,0]); string=['汉宁窗','N=',num2str(N)]; figure(3);[B,A]=fir1(N,Wn,'low',hann(N+1));y_Win=filter(B,A,y);plotspec(y_Win,Ts); case 3 x=win(0,N-1,0,N-1); x=(0.54-0.46*cos(2*pi*n/(N-1))).*x; figure, subplot(1,2,1); stem(n,x,'.'); xlabel('n'); ylabel('x'); string=['汉明窗时域图形','N=',num2str(N)]; text((0.6*N),0.8,string); [H,m]=freqz(x,[1],1024,'whole'); %求其频率响应 mag=abs(H); %得到幅值 db=20*log10((mag+eps)/max(mag)); subplot(1,2,2); plot(m/pi,db); xlabel('w/pi'); ylabel('dB'); title('汉明窗的频率特性(db)'); axis([0,1,-100,0]); string=['汉明窗','N=',num2str(N)]; figure(3);[B,A]=fir1(N,Wn,'low',hamming(N+1));y_Win=filter(B,A,y);plotspec(y_Win,Ts); case 4 x=win(0,N-1,0,N-1); x=(0.42-0.5*cos(2*pi*n/(N-1))+0.08*cos(4*pi*n/(N-1))).*x; figure, subplot(1,2,1); stem(n,x,'.'); xlabel('n'); ylabel('x'); string=['布拉克曼窗时域图形','N=',num2str(N)]; text((0.6*N),0.8,string); [H,m]=freqz(x,[1],1024,'whole'); %求其频率响应 mag=abs(H); %得到幅值 db=20*log10((mag+eps)/max(mag)); subplot(1,2,2); plot(m/pi,db); xlabel('w/pi'); ylabel('dB'); title('布拉克曼窗的频率特性(db)'); axis([0,1,-100,0]); string=['布拉克曼窗','N=',num2str(N)]; figure(3);[B,A]=fir1(N,Wn,'low',blackman(N+1));y_Win=filter(B,A,y);plotspec(y_Win,Ts); end 01-018M
1.算法概述 在通信中,由于信号量噪比的不恒定而影响通信质量。为了对不同的信号强度保持信号量噪比恒定,在理论上要求压缩特性为对数特性。为了使信号量噪比保持恒定,引入A压缩律与μ压缩律以及相应的近似算法-13折线法和15折线法。 对A律13折线法与μ律15折线法进行理论研究,然后利用MATLAB实现仿真,对A律13折线法与μ律15折线法进行性能分析。最后得到一般来说,U律的15折线比A律的13折线,各个段落的斜率都相差2倍,所以小信号的信号量噪比也比A律大一倍,但是对于大信号来说,u律比a律差。 A律压扩其特性可表示为:其中x表示为归一化的压缩器输入电压;y为归一化的压缩器输出电压,A为压扩参数,表示压缩程度。很明显,小信号时为线性特性,大信号时近似为对数特性。这种压扩特性常把压缩、量化和编码合为一体。A律可用13段折线逼近(相当于A=87.6),便于用数字电路实现。13段折线的压缩特性如下图。过程为:第一步:把x(x>0 部分)划分为不均匀的8段。第一分点取在V/2处,然后每段都是剩下部分的1/2。依次取第八段为V~V/2,第七段为V/2~V/4;第一段为V/128~0。第二步:把每段均匀划分为16等份,每一份表示一个量化级,显然8段共16x8=128= 个量化级,需要二进制7位编码表示。可以看出每个量化级是不均匀的。在小信号的量化台阶很小,使小信号时量化噪声减小。如果按均匀量化计算,以最小台阶 为单位,最大信号需用L=128X16=2048=个量化级表示,既需要11位编码。这样非均匀编码使小信号量化台阶缩小了16倍,相当于小信号信噪比改善了20dB。第三步:把y轴均匀划分为8段,每段均匀分为16分。这样y也分为128个量化级,与x轴的128个量化级对应。因此,压扩特性各段的斜率是不同的。第一段斜率其他段为:以上分段为x取正值时的情况。而x取负值时,压扩特性与x取正值成奇对称。在正8段和负8段中,正1,2段和负1,2段斜率相同,合为一段。所以原来的16段折线变为13段折线。U律压扩μ律压扩的数学解析式: 其中:x为输入信号的归一化值;y为压扩后的信号。对话音信号编码,常采用μ=255,这样适量化信噪比改善约24dB。由于上式的是一个近似的对数关系,因此也称为近似对数压缩律,其15折线:近似m律: μ律(m-Law)压扩主要用在北美和日本等地区的数字电话通信中。m为确定压缩量的参数,它反映最大量化间隔和最小量化间隔之比,通常取100≤m≤500。由于m律压扩的输入和输出关系是对数关系,所以这种编码又称为对数PCM。2.仿真效果预览matlab2022a仿真3.MATLAB部分代码预览%本函数针对国际通用的PCM量化mu律15特性近似编码进行解码 % %从文件读入压缩编码 % fid=fopen([name,'.u'],'rb'); % x=fread(fid,'int8'); x=name; s=sign(x); x=abs(x); %归一化 x=x/128; ypcm=zeros(length(x),1); %基于15折线的分段解码映射 for i=1:length(x) if x(i)<1/8 %序列值位于第1折线 ypcm(i)=8/255*x(i); elseif x(i)<2/8 %序列值位于第2折线 ypcm(i)=16/255*(x(i)-1/16); elseif x(i)<3/8 %序列值位于第3折线 ypcm(i)=32/255*(x(i)-5/32); elseif x(i)<4/8 %序列值位于第4折线 ypcm(i)=64/255*(x(i)-17/64); elseif x(i)<5/8 %序列值位于第5折线 ypcm(i)=128/255*(x(i)-49/128); elseif x(i)<6/8 %序列值位于第6折线 ypcm(i)=256/255*(x(i)-129/256); elseif x(i)<7/8 %序列值位于第7折线 ypcm(i)=512/255*(x(i)-321/512); else %序列值位于第8折线 ypcm(i)=1024/255*(x(i)-769/1024); end end %还原符号 ypcm=ypcm.*s; A01-17M
1.算法概述 无线电波的传播环境非常复杂,再加上无线电波自身的多样性,使得电波会通过多种方式和途径从发射天线传播到接收天线。无线视距是指与无线视线相关的路径的长度,它不仅是建立无线传播模型的基础,也被用来区分不同的传播模式。通常情况下,可以按照距离尺度将陆地移动通信无线信号的传播机 制划分为大尺度和小尺度两种。大尺度传播机制主要用于描述发射机与接收机之间长距离的平均信号场强的变化,小尺度传播机制用于描述短 距离内接收信号强度的变化。 按照传播模型的适用环境划分,又可以分为室外传播模型和室内传播模型。按照传播模型的来源划分,可以分为经验模型和确定性模型两种。其中,经验模型是根据大量的测量结果,统计分析后归纳导出的公式;确定性模型则是对具体现场环境直接应用电磁理论计算的方法得到的公式。 一个有效的传播模型应该能很好地预测出传播损耗,该损耗是距离、工作频率和环境参数的函数。由于在实际环境中地形和建筑物的影响,传播损耗也会有所变化,因此预测结果必须在实地测量过程中进一步验证。 无线信道是移动通信的传输媒介,所有的信息都在这个信道中传输。信道性能的优劣直接决定着信息传送的正确率和时效性,进而决定着人们的通信质量。因此,要想在有限的频谱资源上尽可能高质量、大容量传输有用信息,就要求我们必须十分清楚地了解信道的特性,然后根据信道的特性采取一系列的抗干扰和抗衰落技术来保证传输质量和传输容量方面的要求。而对于象认知无线电这样的通过协商利用授权网络空闲时间、空闲频段的无线通信网络,首先就需要实时检测授权网络用户当前未使用的频谱空洞,通过频谱分析,估计相应的参数,并根据非授权用户的需求判断可用的频段和可以达到的通信容量和QoS。 对于授权网络当前的使用状况仍需非授权网络完全通过空中接收、分析授权网络与其用户间的上、下行信号进行判断。更何况就认知无线电的设想而言,它应该解决异构的多种制式的无线网络的共存问题,CR网能够在全频段的频谱范围内快速捕获频谱空洞,进而重新配置网络资源、工作模式和参数。纵向要打破传统的分层概念,采用跨层新协议,横向要打破静态频谱分割方法,不仅动态接入,而且还要自适应地改变频段,改变制式、改变参数,甚至改变网络架构。这就对非授权网络如何通过无线信道获得授权网络信息的能力提出更高的要求。 目前,在实验室里研究移动无线信道普遍使用的是无线信道仿真模型,这比实物试验更能节省费用,并且信道仿真模型复用性高,可以利用其对系统性能进行测试、分析和评估。因此,无线信道仿真模型的研究有着重要的理论和实际意义。业界对无线信道仿真模型的研究由来已久,但多数只考虑了小尺度衰落,但对于认知无线电的研究来说,不单单需要解决小尺度衰落对数字传输技术的影响,最基础的是要解决认知无线电在空中接口上对信息的感知,并且要根据感知的信号强度判断非授权用户的接入是否会对授权网络用户造成干扰以及干扰的程度,进而提出非授权网络用户智接入和退出的机制以及接入和退出阈值的判断和计算,这势必要涉及到大尺度衰落 Okumura-Hata模型,是根据实测数据建立的模型,该模型提供的数据较齐全,应用较广泛,适用于VHF和UHF频段 COST-231Hata模型是EURO-COST组成的COST工作委员会开发的Hata模型的扩展版本,应用频率在1500~2000MHz,适用于小区半径大于1km的宏蜂窝系统,发射有效天线高度在30~200m,接收有效天线高度在1-10m。COST-231Hata模型是COST-231工作委员会提出的将频率扩展到2GHz的Hata模型扩展版本。 COST-231-WI模型广泛用于建筑物高度近似一致的郊区和城区环境,高基站天线时模型采用理论的Walisch-Beroni模型计算多屏绕射损耗,低基站天线时采用测试数据,模型也考虑了自由空间损耗、从建筑物顶到街面的损耗以及街道方向的影响,因此,发射天线可以高于、等于或低于周围建筑物。 2.仿真效果预览matlab2022a仿真3.MATLAB部分代码预览%%%适用条件f=150-1000MHz;Hb=30-100m;Hm=1-10m;d=1-20km%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%wireless_hata_attenuation(Model,f,Hm,Hb,d)%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%发射功率f(MHz),收发天线距离(小区半径)d(km)%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%移动台高度Hm(m),基站高度Hb(m)%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%Model=1;中小城市.Model=2;大城市f<=200MHz.Model=3;大城市f>=400MHz.%%%%%%%%%% %%%%Model=4;郊区.Model=5;农村%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function y=wireless_hata_attenuation(Model,f,Hm,Hb,d) y1=69.55+26.16*log(f)/log(10)-13.82*log(Hb)/log(10)+(44.9-6.55*log(Hb)/log(10))*log(d)/log(10); if Model==1 a=(1.11*log(f)/log(10)-0.7)*Hm-(1.56*log(f)/log(10)-0.8); elseif Model==2 a=8.29*(log(1.54*Hm)/log(10)).^2-1.1; elseif Model==3 a=3.2*(log(11.75*Hm)/log(10)).^2-4.97; elseif Model==4 a=(log(f/28)/log(10)).^2+5.4; elseif Model==5 a=40.98+4.78*(log(f)/log(10)).^2-18.33*log(f)/log(10); else error('no that model'); end y=y1-a; A01-13M
1.算法概述 假设我们的行为准则已经学习好了, 现在我们处于状态s1, 我在写作业, 我有两个行为 a1, a2, 分别是看电视和写作业, 根据我的经验, 在这种 s1 状态下, a2 写作业 带来的潜在奖励要比 a1 看电视高, 这里的潜在奖励我们可以用一个有关于 s 和 a 的 Q 表格代替, 在我的记忆Q表格中, Q(s1, a1)=-2 要小于 Q(s1, a2)=1, 所以我们判断要选择 a2 作为下一个行为. 现在我们的状态更新成 s2 , 我们还是有两个同样的选择, 重复上面的过程, 在行为准则Q 表中寻找 Q(s2, a1) Q(s2, a2) 的值, 并比较他们的大小, 选取较大的一个. 接着根据 a2 我们到达 s3 并在此重复上面的决策过程. Q learning 的方法也就是这样决策的. 看完决策, 我看在来研究一下这张行为准则 Q 表是通过什么样的方式更改, 提升的. 机器学习算法可以分为3种:有监督学习(Supervised Learning)、无监督学习(Unsupervised Learning)和强化学习(Reinforcement Learning),如下图所示: 有监督学习、无监督学习、强化学习具有不同的特点: 有监督学习是有一个label(标记)的,这个label告诉算法什么样的输入对应着什么样的输出,常见的算法是分类、回归等;无监督学习则是没有label(标记),常见的算法是聚类;强化学习强调如何基于环境而行动,以取得最大化的预期利益。主要学习内容:强化学习是什么,奖励思想。强化学习的三种途径。深度强化学习的“深”是什么意思Q-Learning的QTable标签更新公式:Q-Learning的计算步骤:1.判断在当前位置可以有几种操作;2.根据当前位置允许的操作选择一个操作;3.根据选择的操作进行奖赏;4.修改当前行为的本次操作权重;2.仿真效果预览matlab2022a仿真结果如下:3.核心MATLAB代码预览% 移动机器人路径规划仿真平台接口:仿真平台提供了机器人工作环境的仿真界面,利用inf=load('inf'),sp=inf.StartPoint, % EP=inf.EndPoint,WS=inf.env得到机器人工作环境的出发点、目标点位置及障碍物位置信息,工作空间边界及障碍物区域设置为1,自由空间 %设置为0。 gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @Simulation_OpeningFcn, ... 'gui_OutputFcn', @Simulation_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 GridSimulation is made visible. function Simulation_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 GridSimulation (see VARARGIN) % Choose default command line output for GridSimulation handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes GridSimulation wait for user response (see UIRESUME) % uiwait(handles.mainfig); %cd D:\Simulation\EvolvingPath\path cla grid on xlabel('X'); ylabel('Y'); %初始化,获取各对象句柄 handles.StartPoint=findobj('tag','StartPoint'); %获取“设置开始点”按钮句柄 handles.EndPoint=findobj('tag','EndPoint'); %获取“设置目标点”按钮句柄 handles.Obstacle=findobj('tag','Obstacle'); %获取“设置障碍物”按钮句柄 handles.Start=findobj('tag','Start'); %获取“开始运行”按钮句柄 handles.OldEnv=findobj('tag','OldEnv'); %获取“还原环境”按钮句柄 handles.MainAxes=findobj('tag','MainAxes'); %获取主坐标句柄 handles.MainFigure=findobj('tag','MainFigure'); %获取主窗口句柄 %初始化,设置各按钮显示状态 set(handles.StartPoint,'Enable','on') %“设置开始点”按钮可用 set(handles.EndPoint,'Enable','off') %“设置目标点”按钮禁用 set(handles.Obstacle,'Enable','off') %“设置障碍物”按钮禁用 set(handles.Start,'Enable','off') %“开始运行”按钮禁用 set(handles.OldEnv,'Enable','off') %“还原环境”按钮可用 set(handles.MainFigure,'WindowButtonDownFcn',''); % set(handles.MainFigure,'WindowButtonUpFcn',''); % set(handles.MainAxes,'ButtonDownFcn',''); % set(handles.MainAxes,'ButtonDownFcn',''); % inf=load('inf'); %打开环境信息文件,inf.mat由save命令创建,存储了开始点、目标点、障碍物信息等 XLim=20; %x轴最大取值 YLim=20; %y轴最大取值 BreakTask=0; %初始化终止任务变量 for i=1:XLim %将边界设置成障碍物 for j=1:YLim if ((i==1)|(i==XLim)|(j==1)|(j==YLim)) ws(i,j)=1; end end end save('inf','ws','-append'); save('inf','BreakTask','-append'); % --- Outputs from this function are returned to the command line. function varargout = Simulation_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 StartPoint. function StartPoint_Callback(hObject, eventdata, handles) % hObject handle to StartPoint (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) set(handles.StartPoint,'Enable','off') set(handles.EndPoint,'Enable','on') set(handles.Obstacle,'Enable','off') set(handles.Start,'Enable','off') flag=0; save('inf','flag','-append'); set(handles.MainFigure,'WindowButtonDownFcn',''); set(handles.MainFigure,'WindowButtonUpFcn',''); set(handles.MainAxes,'ButtonDownFcn','PathPlanning(''MainAxes_ButtonDownFcn'',gcbo,[],guidata(gcbo))'); % --- Executes on button press in EndPoint. function EndPoint_Callback(hObject, eventdata, handles) % hObject handle to EndPoint (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) set(handles.StartPoint,'Enable','off') set(handles.EndPoint,'Enable','off') set(handles.Obstacle,'Enable','on') set(handles.Start,'Enable','on') flag=1; save('inf','flag','-append'); %set(handles.MainFigure,'WindowButtonDownFcn',''); %set(handles.MainFigure,'WindowButtonUpFcn',''); set(handles.MainAxes,'ButtonDownFcn','PathPlanning(''MainAxes_ButtonDownFcn'',gcbo,[],guidata(gcbo))'); % --- Executes on mouse press over axes background. function MainAxes_ButtonDownFcn(hObject, eventdata, handles) % hObject handle to MainAxes (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) inf=load('inf'); flag=inf.flag; start_end=inf.start_end; p=get(handles.MainAxes,'CurrentPoint'); hold on; if(flag==0) p=round(p); start_end(1,1)=p(1,1);start_end(1,2)=p(1,2); %记录起点信息,给inf.mat文件赋值 StartPoint(1,1)=p(1,1);StartPoint(1,2)=p(1,2); %为当前点赋值,当前点为起点的位置信息 save('inf','StartPoint','-append'); HRobot=plot(start_end(1,1),start_end(1,2),'pentagram'); %画开始点位置 text(start_end(1,1)-.5,start_end(1,2)-.5,'Start'); RobotDirection=inf.RobotDirection;%机器人方向应该是传递参数 x=start_end(1,1); y=start_end(1,2); RobotPosX=x; RobotPosY=y; save('inf','RobotPosX','-append'); save('inf','RobotPosY','-append'); else p=round(p); start_end(2,1)=p(1,1);start_end(2,2)=p(1,2); EndPoint(1,1)=p(1,1);EndPoint(1,2)=p(1,2); %为当前点赋值,当前点为结束点的位置信息 EndPoint=round(EndPoint); save('inf','EndPoint','-append'); plot(start_end(2,1),start_end(2,2),'*','color','r') text(start_end(2,1)-.5,start_end(2,2)+.5,'Goal'); end save('inf','start_end','-append'); set(handles.MainAxes,'ButtonDownFcn',''); set(handles.MainAxes,'ButtonDownFcn',''); % --- Executes on button press in Obstacle. function Obstacle_Callback(hObject, eventdata, handles) % hObject handle to Obstacle (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) env=zeros(50); save('inf','env','-append'); set(handles.StartPoint,'Enable','off') set(handles.EndPoint,'Enable','off') set(handles.Obstacle,'Enable','on') set(handles.Start,'Enable','on') set(handles.OldEnv,'Enable','on') %“开始运行”按钮禁用 set(handles.MainFigure,'WindowButtonDownFcn','PathPlanning(''MainFigure_WindowButtonDownFcn'',gcbo,[],guidata(gcbo))'); %set(handles.MainFigure,'WindowButtonUpFcn','PathPlanning(''MainFigure_WindowButtonUpFcn'',gcbo,[],guidata(gcbo))'); function MainFigure_WindowButtonDownFcn(hObject, eventdata, handles) % hObject handle to MainFigure (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) inf=load('inf'); ws=inf.env; Pos=get(handles.MainAxes,'CurrentPoint'); Pos=round(Pos); XPos=Pos(1,1);YPos=Pos(1,2); %当前点坐标 X=[XPos-.5,XPos-.5,XPos+.5,XPos+.5]; Y=[YPos-.5,YPos+.5,YPos+.5,YPos-.5]; fill(X,Y,[0 0 0]) %画障碍物 text(13-.2,12,'B','color',[1 1 1]); text(7-.2,8,'A','color',[1 1 1]); % for i=XPos-1:XPos+1 % for j=YPos-1:YPos+1 % if((i>0)&(i<=XLim)) %防止出现环境矩阵元素下标为零 % if((j>0)&(j<=YLim)) ws(XPos,YPos)=1; % end % end % end %end env=ws; save('inf','env','-append'); % --- Executes on button press in SensorChecked. function SensorChecked_Callback(hObject, eventdata, handles) % hObject handle to SensorChecked (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hint: get(hObject,'Value') returns toggle state of SensorChecked function RobotVelocity_Callback(hObject, eventdata, handles) %设置机器人运行速度 % hObject handle to RobotVelocity (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 RobotVelocity as text % str2double(get(hObject,'String')) returns contents of RobotVelocity as a double function RobotRadius_Callback(hObject, eventdata, handles) %设置机器人半径 % hObject handle to RobotRadius (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 RobotRadius as text % str2double(get(hObject,'String')) returns contents of RobotRadius as a double % --- Executes during object creation, after setting all properties. function SensorMaxValue_Callback(hObject, eventdata, handles) %设置传感器测量范围 % hObject handle to SensorMaxValue (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 SensorMaxValue as text % str2double(get(hObject,'String')) returns contents of SensorMaxValue as a double function Handbook_Callback(hObject, eventdata, handles) %系统简介 % hObject handle to Handbook (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) uiopen('系统简介.txt',1) function ClearScreen_Callback(hObject, eventdata, handles) %重新开始 % hObject handle to ClearScreen (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) set(handles.StartPoint,'Enable','on') %“设置开始点”按钮可用 set(handles.EndPoint,'Enable','off') %“设置目标点”按钮禁用 set(handles.Obstacle,'Enable','off') %“设置障碍物”按钮禁用 set(handles.Start,'Enable','off') %“开始运行”按钮禁用 cla clear all % --- Executes on button press in OldEnv. function OldEnv_Callback(hObject, eventdata, handles) % hObject handle to OldEnv (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) XLim=20; %x轴最大取值 YLim=20; %y轴最大取值 inf=load('inf'); ws=inf.env; %得到障碍物信息 SP=inf.StartPoint; %出发点位置 EP=inf.EndPoint; %目标点位置 set(handles.StartPoint,'Enable','off') set(handles.EndPoint,'Enable','off') set(handles.Obstacle,'Enable','off') set(handles.Start,'Enable','on') HandleStart=line([SP(1,1) SP(1,1)],[SP(1,2) SP(1,2)]); %设置开始点 text(SP(1,1)-.5,SP(1,2)-.5,'Start'); HandleTarget=line([EP(1,1) EP(1,1)],[EP(1,2) EP(1,2)]); %设置目标点 text(EP(1,1)-.5,EP(1,2)+.5,'Goal'); set(HandleStart,'marker','pentagram') set(HandleTarget,'marker','*','color','r') for i=1:XLim %将边界设置成障碍物 for j=1:YLim if ((i==1)|(i==XLim)|(j==1)|(j==YLim)) ws(i,j)=1; end end end for i=2:XLim-1 %还原障碍物信息 for j=2:YLim-1 if((ws(i,j)==1)) X=[i-.5,i-.5,i+.5,i+.5]; Y=[j-.5,j+.5,j+.5,j-.5]; fill(X,Y,[0 0 0]); %设置障碍物 end end end X=[1-.5,1-.5,1+.5,1+.5]; Y=[6-.5,6+.5,6+.5,6-.5]; fill(X,Y,[0 0 0]); %设置障碍物 X=[1-.5,1-.5,1+.5,1+.5]; Y=[14-.5,14+.5,14+.5,14-.5]; fill(X,Y,[0 0 0]); %设置障碍物 X=[10-.5,10-.5,10+.5,10+.5]; Y=[1-.5,1+.5,1+.5,1-.5]; fill(X,Y,[0 0 0]); %设置障碍物 text(13-.2,12,'B','color',[1 1 1]); text(7-.2,8,'A','color',[1 1 1]); X=[0,0,.5,.5]; Y=[0,YLim,YLim,0]; fill(X,Y,[0 0 0]); %设置边界为障碍物 X=[XLim-.5,XLim-.5,XLim,XLim]; Y=[0,YLim,YLim,0]; fill(X,Y,[0 0 0]); %设置边界为障碍物 X=[0,0,XLim,XLim]; Y=[YLim-.5,YLim,YLim,YLim-.5]; fill(X,Y,[0 0 0]); %设置边界为障碍物 X=[0,0,XLim,XLim]; Y=[0,.5,.5,0]; fill(X,Y,[0 0 0]); %设置边界为障碍物 %axis([0 20 0 20]) %机器人当前位置设置为开始位置 RobotPosX=SP(1,1); RobotPosY=SP(1,2); save('inf','RobotPosX','-append'); save('inf','RobotPosY','-append'); function RobotSingleLength_Callback(hObject, eventdata, handles) %设置单步运行距离 % hObject handle to RobotSingleLength (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 RobotSingleLength as text % str2double(get(hObject,'String')) returns contents of RobotSingleLength as a double function BreakTask_Callback(hObject, eventdata, handles) % hObject handle to BreakTask (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) BreakTask=1; inf=load('inf'); save('inf','BreakTask','-append'); function SaveAs_Callback(hObject, eventdata, handles) % hObject handle to SaveAs (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) %saveas(hObject,'g.bmp'); %print(gcf, '-depsc','-tiff','-r600','test.eps') %saveas(gcf, 'test.eps', 'psc2') %pause axes(handles.MainAxes); %取得axes1的句柄 if isempty(handles.MainAxes) return; end newFig = figure;%由于直接保存axes1上的图像有困难,所以保存在新建的figure中的谱图 set(newFig,'Visible','off','color',[1,1,1])%设置新建的figure为不可见 newAxes = copyobj(handles.MainAxes,newFig); %将axes1中的图复制到新建的figure中 set(newAxes,'Units','default','Position','default'); % 设置图显示的位置 [filename,pathname] = uiputfile({ '*.tif','figure type(*.tif)'}, '结果另存为'); if isequal(filename,0)||isequal(pathname,0)%如果用户选择“取消”,则退出 return; else fpath=fullfile(pathname,filename); end f = getframe(newFig); f = frame2im(f); imwrite(f, fpath); %saveas(newFig,'filename.eps') %close(newFig) %移动机器人路径规划仿真平台程序 END END END END END END END END END END END END END END END END END END END % -------------------------------------------------------------------- function MainFigure_WindowButtonMotionFcn(hObject, eventdata, handles) % hObject handle to MainFigure (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) %h=get(handles.MainFigure,'SelectionType') function RobotRadius_CreateFcn(hObject, eventdata, handles) % hObject handle to RobotRadius (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 function mainfig_CreateFcn(hObject, eventdata, handles) % hObject handle to mainfig (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 creation, after setting all properties. function MainFigure_CreateFcn(hObject, eventdata, handles) % hObject handle to MainFigure (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 Start. % --- Executes during object creation, after setting all properties. function RobotSingleLength_CreateFcn(hObject, eventdata, handles) % hObject handle to RobotSingleLength (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 % --- Executes during object creation, after setting all properties. function SensorMaxValue_CreateFcn(hObject, eventdata, handles) % hObject handle to SensorMaxValue (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 % --- Executes during object creation, after setting all properties. function RobotVelocity_CreateFcn(hObject, eventdata, handles) % hObject handle to RobotVelocity (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 function Sensor1Length_Callback(hObject, eventdata, handles) % hObject handle to Sensor1Length (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 Sensor1Length as text % str2double(get(hObject,'String')) returns contents of Sensor1Length as a double % --- Executes during object creation, after setting all properties. function Sensor1Length_CreateFcn(hObject, eventdata, handles) % hObject handle to Sensor1Length (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 function Sensor2Length_Callback(hObject, eventdata, handles) % hObject handle to Sensor2Length (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 Sensor2Length as text % str2double(get(hObject,'String')) returns contents of Sensor2Length as a double % --- Executes during object creation, after setting all properties. function Sensor2Length_CreateFcn(hObject, eventdata, handles) % hObject handle to Sensor2Length (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 function Sensor3Length_Callback(hObject, eventdata, handles) % hObject handle to Sensor3Length (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 Sensor3Length as text % str2double(get(hObject,'String')) returns contents of Sensor3Length as a double % --- Executes during object creation, after setting all properties. function Sensor3Length_CreateFcn(hObject, eventdata, handles) % hObject handle to Sensor3Length (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 function Sensor4Length_Callback(hObject, eventdata, handles) % hObject handle to Sensor4Length (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 Sensor4Length as text % str2double(get(hObject,'String')) returns contents of Sensor4Length as a double % --- Executes during object creation, after setting all properties. function Sensor4Length_CreateFcn(hObject, eventdata, handles) % hObject handle to Sensor4Length (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 function Sensor5Length_Callback(hObject, eventdata, handles) % hObject handle to Sensor5Length (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 Sensor5Length as text % str2double(get(hObject,'String')) returns contents of Sensor5Length as a double % --- Executes during object creation, after setting all properties. function Sensor5Length_CreateFcn(hObject, eventdata, handles) % hObject handle to Sensor5Length (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 function Sensor6Length_Callback(hObject, eventdata, handles) % hObject handle to Sensor6Length (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 Sensor6Length as text % str2double(get(hObject,'String')) returns contents of Sensor6Length as a double % --- Executes during object creation, after setting all properties. function Sensor6Length_CreateFcn(hObject, eventdata, handles) % hObject handle to Sensor6Length (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 function Sensor7Length_Callback(hObject, eventdata, handles) % hObject handle to Sensor7Length (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 Sensor7Length as text % str2double(get(hObject,'String')) returns contents of Sensor7Length as a double % --- Executes during object creation, after setting all properties. function Sensor7Length_CreateFcn(hObject, eventdata, handles) % hObject handle to Sensor7Length (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 function Sensor8Length_Callback(hObject, eventdata, handles) % hObject handle to Sensor8Length (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 Sensor8Length as text % str2double(get(hObject,'String')) returns contents of Sensor8Length as a double % --- Executes during object creation, after setting all properties. function Sensor8Length_CreateFcn(hObject, eventdata, handles) % hObject handle to Sensor8Length (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 % -------------------------------------------------------------------- function RobotPosX_Callback(hObject, eventdata, handles) % hObject handle to RobotPosX (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 RobotPosX as text % str2double(get(hObject,'String')) returns contents of RobotPosX as a double % --- Executes during object creation, after setting all properties. function RobotPosX_CreateFcn(hObject, eventdata, handles) % hObject handle to RobotPosX (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 function RobotPosY_Callback(hObject, eventdata, handles) % hObject handle to RobotPosY (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 RobotPosY as text % str2double(get(hObject,'String')) returns contents of RobotPosY as a double % --- Executes during object creation, after setting all properties. function RobotPosY_CreateFcn(hObject, eventdata, handles) % hObject handle to RobotPosY (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 % --- Executes on selection change in popupmenu6. function popupmenu6_Callback(hObject, eventdata, handles) % hObject handle to popupmenu6 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: contents = get(hObject,'String') returns popupmenu6 contents as cell array % contents{get(hObject,'Value')} returns selected item from popupmenu6 % --- Executes during object creation, after setting all properties. function popupmenu6_CreateFcn(hObject, eventdata, handles) % hObject handle to popupmenu6 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: popupmenu 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 function RobotDirection_Callback(hObject, eventdata, handles) % hObject handle to RobotDirection (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 RobotDirection as text % str2double(get(hObject,'String')) returns contents of RobotDirection as a double % --- Executes during object creation, after setting all properties. function RobotDirection_CreateFcn(hObject, eventdata, handles) % hObject handle to RobotDirection (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 % --- Executes on button press in Start. function Start_Callback(hObject, eventdata, handles) % hObject handle to Start (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % --- Executes on selection change in Tasklistbox. function Tasklistbox_Callback(hObject, eventdata, handles) % hObject handle to Tasklistbox (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: contents = get(hObject,'String') returns Tasklistbox contents as cell array % contents{get(hObject,'Value')} returns selected item from Tasklistbox % --- Executes during object creation, after setting all properties. function Tasklistbox_CreateFcn(hObject, eventdata, handles) % hObject handle to Tasklistbox (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: listbox 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 % --- Executes on selection change in AlgorithmListBox. function AlgorithmListBox_Callback(hObject, eventdata, handles) % hObject handle to AlgorithmListBox (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: contents = get(hObject,'String') returns AlgorithmListBox contents as cell array % contents{get(hObject,'Value')} returns selected item from AlgorithmListBox % --- Executes during object creation, after setting all properties. function AlgorithmListBox_CreateFcn(hObject, eventdata, handles) % hObject handle to AlgorithmListBox (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: listbox 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 A_006
1.算法概述 CDMA技术的基础是扩频通信。扩频:用来传输信息的信号带宽远远大于信息本身带宽的一种传输方式,频带的扩展由独立于信息的扩频码来实现,与所传信息数据无关,在接收端用同步接收实现解扩和数据恢复。如图2-1,我们可以知道CDMA系统的基本原理和TDMA、FDMA的区别。 这个公式表明,在高斯信道中当传输系统的信号噪声功率比S/N下降时,可用增加系统传输带宽W的办法来保持信道容量C不变。对于任意给定的信号噪声功率比,可以用增大传输带宽来获得较低的信息差错率。正因为这个原因,扩频通信具有比较强的抗噪声干扰的能力。CDMA技术是以扩频通信为基础的载波调制和多址接入技术,所以如何实现扩频部分对于整个CDMA系统的实现有着重要的影响。 CDMA技术是以扩频通信为基础的载波调制和多址接入技术,所以如何实现扩频部分对于整个CDMA系统的实现有着重要的影响。下图是CDMA系统的基本原理图: 信号经信源编码后成为数字信号,经过纠错编码、卷积编码和交织等相关处理后送入调制器中,利用PN码发生器产生的高速PN码将数字信号变成码片,使得信号的传输带宽远大于信号本身的带宽以实现扩频通信,同时,为了使信号的传输与信道特性相匹配,必须用载波发生器产生的载波去调制扩频信号。使其频率变为适合信道传愉的射频频段,将数字信号调制成模拟信号后通过放大器发射出去。在接收端,利用下变频器将射频信号还原成中频信号,采用与发射端相同的信号处理技术再将信号还原成原始信号,从而达到数据通信传输的目的。 针对本课题所要求的CDMA发送端的设计,主要从以下几个方面去研究,数据处理模块、差分编码模块、PN码序列产生模块、扩频模块。其中数据处理模块主要是用来完成数据的串/并变换;差分编码模块主要用于对数据先进行差分编码;PN码序列产生模块是扩频通信模块中比较重要的模块,其具体的作用和功能我们将在具体实践中做具体研究和讨论;扩频模块是发射端的核心模块,主要用于完成数据的扩频。图2-3就是CDMA系统模块化以后的基本结构,其中虚线框内的部分就是CDMA数字基带发送部分,本课题我们主要就是完成下图中上半部分,此外,在此基础上将对接收部分做简单的介绍。图中发送端和接收端的Walsh码发生器和PN码发生器其实是同一个模块,它们的区别仅仅是延迟不同。 由上图可知,这个系统一共有两个模块组成——调制模块和解调模块。其中调制模块是信号发生器产生4路输入信号,经WALSH调制、PN扩频、基带求和与并/串变换成为1路信号,完成调制。而解调模块主要是将收到的1路信号首先进行串并转换,在取得同步的基础上进行PN解扩和WALSH解调从而恢复出4路信息。该系统框图就是我们所要实现的系统的基本结构,具体实现方法、步骤、以及原理分析及优化我将针对每个模块,在后面给予具体研究。2.仿真效果预览3.MATLAB程序............................................................. %串----并for i=1:31 for j=1:16 pn_walsh_user_rec(i,j)=pn_walsh_user_c(i*j); endend%pn解扩for i=1:31 for j=1:16 walsh_user_rec(i,j)=pn_walsh_user_rec(i,j)*pn(i); endend for i=1:31 for j=1:16 walsh_user_rec2(j)=walsh_user_rec(i,j); endend %walsh解扩 user_rec2(1,1)=walsh_user_rec2(1); user_rec2(1,2)=walsh_user_rec2(2); user_rec2(1,3)=walsh_user_rec2(3); user_rec2(1,4)=walsh_user_rec2(4); user_rec2(2,1)=walsh_user_rec2(5); user_rec2(2,2)=walsh_user_rec2(6); user_rec2(2,3)=walsh_user_rec2(7); user_rec2(2,4)=walsh_user_rec2(8); user_rec2(3,1)=walsh_user_rec2(9); user_rec2(3,2)=walsh_user_rec2(10); user_rec2(3,3)=walsh_user_rec2(11); user_rec2(3,4)=walsh_user_rec2(12); user_rec2(4,1)=walsh_user_rec2(13); user_rec2(4,2)=walsh_user_rec2(14); user_rec2(4,3)=walsh_user_rec2(15); user_rec2(4,4)=walsh_user_rec2(16); for i=1:4 for j=1:4 rec(i,j)= user_rec2(i,j)*walsh(i,j); end end %===============接收信号=================================== rec_signal= user_rec2(1,1:4); %========画信号============================================================== if t==1 figure; subplot(511) stairs(1:4,user,'r');%用户信号 axis([1,4,-2,2]); title('用户发送的信号') subplot(512)%随机码 stairs(1:31,pn); axis([1,31,-2,2]); title('随机码') subplot(513)%调制WALSH stairs(1:16,walsh_user2,'r'); axis([1,16,-2,2]); title('调制WALSH') subplot(514) %发送 stairs(1:496,pn_walsh_user_c); axis([1,496,-2,2]); title('发送信号') subplot(515) %数据接收 stairs(1:4,rec_signal,'r'); axis([1,4,-2,2]); title('数据接收信号') hold on;endend figure;subplot(411);stairs(1:32,user0);axis([1,32,-2,2]);title('user0数据接收信号') subplot(412);stairs(1:32,user1);axis([1,32,-2,2]);title('user1数据接收信号') subplot(413);stairs(1:32,user2);axis([1,32,-2,2]);title('user2数据接收信号') subplot(414);stairs(1:32,user3);axis([1,32,-2,2]);title('user3数据接收信号') %%%=====================以上是加上噪声的 误码率测试=================================================prompt={'请输入用户个数:','请输入用户发送信息个数:','请输入用户码功率','请输入噪声功率','请输入要测试的用户ID号'};name=['码分多址复用技术测试'];line=1; defaultanswer={'4','100','1 2 3 4', '10','1'}; glabel=inputdlg(prompt,name,line,defaultanswer);%对话框num1=str2num(char(glabel(1,1))); %对话框num2=str2num(char(glabel(2,1))); %对话框num3=str2num(char(glabel(3,1))); %对话框num4=str2num(char(glabel(4,1))); %对话框k=str2num(char(glabel(5,1))); %对话框 UserNumber=num1;%用户数inflength=num2;%用户信息序列长度a=num3; %用户信息功率Pn=num4; %噪声功率sigma=1;%噪声标准差 %==========================================================================N=31;%伪随即序列的阶数R=(ones(UserNumber)+(N-1)*eye(UserNumber))/N; %相关系数矩阵b=2*round(rand(UserNumber,inflength))-1; %用户信息矩阵(随机+1,-1矩阵)coefficients=[1 0 1 0 0]; %5级左移m序列码发生器的反馈系数mseq=mseries(coefficients); %生成31×31的m序列码矩阵mseq=mseq(1:UserNumber,1:N);%==================以上生成随即序列========================================.............................................01_001_m
2023年03月