⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 untitled.asv

📁 本文采用matlab语言编写了数字基带传输系统的模拟实现
💻 ASV
字号:
function varargout = untitled(varargin)
% UNTITLED M-file for untitled.fig
%      UNTITLED, by itself, creates a new UNTITLED or raises the existing
%      singleton*.
%
%      H = UNTITLED returns the handle to a new UNTITLED or the handle to
%      the existing singleton*.
%
%      UNTITLED('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in UNTITLED.M with the given input arguments.
%
%      UNTITLED('Property','Value',...) creates a new UNTITLED or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before untitled_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to untitled_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 help untitled

% Last Modified by GUIDE v2.5 09-Jun-2006 19:08:35

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @untitled_OpeningFcn, ...
                   'gui_OutputFcn',  @untitled_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 untitled is made visible.
function untitled_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 untitled (see VARARGIN)

% Choose default command line output for untitled
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes untitled wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = untitled_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 Untitled_1_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function Untitled_2_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
set(handles.text5, 'String', '点击Yes关闭当前窗口');
answer=questdlg('您要关闭窗口吗?','关闭','Yes','No','Cancel','Yes');%打开提问对话框,确认是否关闭当前窗口
switch answer                  %如果选择OK则关闭当前窗口
    case 'Yes'
    close
    case 'No'
    case 'Cancel'
 end


% --------------------------------------------------------------------
function Untitled_3_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
set(handles.text5, 'String', '在对话框中选择一种方式后点击OK');
a=handles.metricdata.density%把输入的值赋给a
if a>1                      %判断输入是否合法
    errordlg('输入必须在0-1之间','Error');
else if a<0
    errordlg('输入必须在0-1之间','Error');
    else
    str={'有噪声','无噪声'};
    [Selection,ok]=listdlg('ListString',str,'Name','选择一种方式','PromptString','请选择','SelectionMode','Single');%打开菜单对话框,用以选择所要仿真的类型,对于升余弦滚降系统,分为"有噪声"和"无噪声"


alpha=a;%滚降系数
N=2^14;  %采样点数
L=32;  %每码元采样点
M=N/L;  %码元数
Rb=2;   %码速率
Ts=1/Rb;  %码元间隔
dt=Ts/L;  %时域采样间隔
df=1/(N*dt);  %频域采样间隔
T=N*dt;  %截短时宽
Bs=N*df/2;  %频带宽度
Na=4;   %画眼图一次四个码元
t=[-T/2+dt/2:dt:T/2];   %时域坐标
f=[-Bs+df/2:df:Bs];   %频域坐标
g1=sin(pi*t/Ts)./(pi*t/Ts);
g2=cos(alpha*pi*t/Ts)./(1-(2*alpha*t/Ts).^2);
g=g1.*g2;%升余弦脉冲波形
G=t2f(g,dt); %系统总的频谱

a=sign(randn(1,M));
imp=zeros(1,N);
imp(L/2:L:N)=a/dt;%产生冲击序列
S=t2f(imp,dt).*G;%升余弦信号的傅立叶变换
if ok==1
switch Selection%使用switch语句对菜单对话框进行控制
    case 1%当选择"有噪声"时,执行以下的函数
       
        s=f2t(S,dt);%升余弦信号的时域波形
        s=real(s)+0.2*randn(1,N);
        
        set(handles.text2, 'String', '噪声情况下的眼图');
        axes(handles.axes2);%在第二个坐标系中绘制噪声情况下的眼图
        cla;
        hold on
        grid
             
        %画眼图
        tt=[0:dt:Na*L*dt];
        for jj=1:Na*L:N-Na*L
             plot(tt,s(jj:jj+Na*L))
        end
      
        axes(handles.axes1);%在第一个坐标系中绘制系统总的频谱
        cla;
        plot(f,abs(G))
        grid 
        axis([-2,2,min(abs(G)),max(abs(G))]);
     case 2%当选择"无噪声"时,执行以下的函数
            
        set(handles.text2, 'String', '无噪声情况下的眼图');
        
        s=f2t(S,dt);%升余弦信号的时域波形
        s=real(s);
        
        axes(handles.axes2);%在第二个坐标系中绘制无噪声情况下的眼图
        cla;
        hold on
        grid
        %画眼图
        tt=[0:dt:Na*L*dt];
        for jj=1:Na*L:N-Na*L
             plot(tt,s(jj:jj+Na*L))
        end
    
        
        axes(handles.axes1);%在第一个坐标系中绘制系统总的频谱
        cla;
        plot(f,abs(G))
        grid 
        axis([-2,2,min(abs(G)),max(abs(G))]);
  end;
else 
end;
end
end
% --------------------------------------------------------------------
function Untitled_5_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
a=handles.metricdata.density%把输入的值赋给a
 set(handles.text5, 'String', '在对话框中选择一种方式后点击OK');
if a>1%判断输入是否合法
    errordlg('输入必须在0-1之间','Error');
else if a<0
    errordlg('输入必须在0-1之间','Error');
    else
    str={'均衡前','均衡后'};
    [Selection,ok]=listdlg('ListString',str,'Name','选择一种方式','PromptString','请选择','SelectionMode','Single');%打开菜单对话框,用以选择所要仿真的类型,对于多径传播,分为"均衡前"和"均衡后"
   
alpha=a;
N=2^14;  %采样点数
L=32;  %每码元采样点数
M=N/L;  %码元数
Rb=2;   %码速率
Ts=1/Rb;  %码元间隔
dt=Ts/L;  %时域采样间隔
df=1/(N*dt);  %频域采样间隔
d=16;  %半个码元采样点数
T=N*dt;  %截短时宽
Bs=N*df/2;  %频带宽度
Na=4;   %画眼图一次四个码元
t=[-T/2+dt/2:dt:T/2];  %时域坐标
f=[-Bs+df/2:df:Bs];  %频域坐标

g1=sin(pi*t/Ts)./(pi*t/Ts);
g2=cos(alpha*pi*t/Ts)./(1-(2*alpha*t/Ts).^2);
g=g1.*g2;%升余弦脉冲波形
Cf=1-0.5*exp(-2*i*pi*f*d); %信道传输函数

a=sign(randn(1,M));
imp=zeros(1,N);
imp(L/2:L:N)=a/dt;%产生冲击序列
if ok==1
switch Selection%使用switch语句对菜单对话框进行控制
    case 1%当选择"均衡前"时,执行以下的函数
        set(handles.text2, 'String', '多径均衡前的眼图');
           
        G=t2f(g,dt).*Cf; %系统总的频谱
        S=t2f(imp,dt).*G; %序列在频域通过系统
        s=f2t(S,dt); %转换到时域
        s=real(s)+0*randn(1,N); %可加入随机噪声
        
        %预设眼图的位置
        axes(handles.axes2);%在第三个坐标系中绘制多径均衡前的眼图
        cla;
        hold on
        grid
        %画眼图
        tt=[0:dt:Na*L*dt];
	    for jj=1:Na*L:N-Na*L
             plot(tt,s(jj:jj+Na*L))
        end
 
        axes(handles.axes1);%在第一个坐标系中绘制系统总的频谱
        cla;
        plot(f,abs(G))
        axis([-2,2,min(abs(G)),max(abs(G))]);
       
        
    case 2%当选择"均衡后"时,执行以下的函数
        set(handles.text2, 'String', '多径均衡后的眼图');
        G=t2f(g,dt).*Cf.*1./Cf; %系统总的频谱
        S=t2f(imp,dt).*G; %序列在频域通过系统
        s=f2t(S,dt); %转换到时域
        s=real(s); 
        
        axes(handles.axes2);%在第三个坐标系中绘制多径均衡后的眼图
        cla;
        hold on
        grid
        %画眼图
        tt=[0:dt:Na*L*dt];
	    for jj=1:Na*L:N-Na*L
             plot(tt,s(jj:jj+Na*L))
        end
        
        axes(handles.axes1);%在第一个坐标系中绘制系统总的频谱
        cla;
        plot(f,abs(G))
        grid 
        axis([-2,2,min(abs(G)),max(abs(G))]);
  end;
else
end
 end
end
   


% --------------------------------------------------------------------
function run_Callback(hObject, eventdata, handles)
% hObject    handle to run (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------





% --------------------------------------------------------------------
function close_Callback(hObject, eventdata, handles)
% hObject    handle to close (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)




% --------------------------------------------------------------------
function Untitled_6_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function Untitled_7_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_7 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
set(handles.text5, 'String', '在对话框中选择一种方式后点击OK');
a=handles.metricdata.density%把输入的值赋给a

if a>1%判断输入是否合法
    errordlg('输入必须在0-1之间','Error');
else if a<0
    errordlg('输入必须在0-1之间','Error');
    else
    str={'不加网孔','加网孔'};
    [Selection,ok]=listdlg('ListString',str,'Name','选择一种方式','PromptString','请选择','SelectionMode','Single');%打开菜单对话框,用以选择所要仿真的类型,对于多径传播,分为"有均衡"和"无均衡"

alpha=a;
set(handles.text1, 'String', '网孔滤波特性');   
N=2^14;  %采样点数
L=32;  %每码元采样点数
M=N/L;  %码元数
Rb=2;   %码速率
Ts=1/Rb;  %码元间隔
dt=Ts/L;  %时域采样间隔
df=1/(N*dt);  %频域采样间隔
T=N*dt;  %截短时宽
Bs=N*df/2;  %频带宽度
Na=4;   %画眼图一次四个码元
        
t=[-T/2+dt/2:dt:T/2];   %时域坐标
f=[-Bs+df/2:df:Bs];   %频域坐标
a=round(rand(1,M));
rz=zeros(1,N);
for tt=1:L
    rz(tt+[0:M-1]*L)=a;
end
    RZ=t2f(rz,dt);
        
WK=(pi*f*Ts)./sin(pi*f*Ts);%网孔均衡

g1=sin(pi*t/Ts)./(pi*t/Ts);
g2=cos(alpha*pi*t/Ts)./(1-(2*alpha*t/Ts).^2);
g=g1.*g2;%升余弦脉冲波形
H=t2f(g,dt); %系统总的频谱
G= RZ;%G为不归零脉冲序列

S2=G.*WK.*H;%加网孔,升余弦滚降
S3=G.*H;%不加网孔,直接滚降
s2=real(f2t(S2,dt));
s3=real(f2t(S3,dt));
tt=[0:dt:Na*L*dt]; 
if ok==1%判断对话框中OK键是否被按下
switch Selection
    case 1
        set(handles.text2, 'String', '不加网孔时的眼图');   
        axes(handles.axes1);%在第一个坐标系中绘制网孔滤波特性曲线
        cla;
        plot(f,abs(WK))
        grid
        axis([0,1/Ts,0,10])
        %画眼图
        axes(handles.axes2);%在第二个坐标系中绘制不加网孔时的眼图
        cla;
        for jj=1:Na*L:N/2
                plot(tt,s3(jj:jj+Na*L));
                hold on
        end

    case 2
        set(handles.text2, 'String', '加网孔时的眼图'); 
        axes(handles.axes1);%在第一个坐标系中绘制网孔滤波特性曲线
        cla;
        plot(f,abs(WK))
        grid
        axis([0,1/Ts,0,10])
        %画眼图
        axes(handles.axes2);%%在第二个坐标系中绘制加网孔时的眼图
        cla;
        for jj=1:Na*L:N/2
                plot(tt,s2(jj:jj+Na*L));
                hold on
       end
end
else
end
end
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
density = str2double(get(hObject, 'String'));%获取输入的滚降系数的值,将其赋给density

handles.metricdata.density = density;
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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -