📄 dscdma.m
字号:
function varargout = DSCDMA(varargin)
% DSCDMA M-file for DSCDMA.fig
% DSCDMA, by itself, creates a new DSCDMA or raises the existing
% singleton*.
%
% H = DSCDMA returns the handle to a new DSCDMA or the handle to
% the existing singleton*.
%
% DSCDMA('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in DSCDMA.M with the given input arguments.
%
% DSCDMA('Property','Value',...) creates a new DSCDMA or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before DSCDMA_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to DSCDMA_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 DSCDMA
% Last Modified by GUIDE v2.5 22-Mar-2009 13:32:56
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @DSCDMA_OpeningFcn, ...
'gui_OutputFcn', @DSCDMA_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 DSCDMA is made visible.
function DSCDMA_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 DSCDMA (see VARARGIN)
% Choose default command line output for DSCDMA
handles.output = hObject;
global err
load err
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes DSCDMA wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = DSCDMA_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 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)
% ----------------------------------------------------------------------- %
snr_in_dB = 0:5:30;
u = max_length([1 0 0 1 0 1]);
v = max_length([1 1 0 1 1 1]);
gold = mod(u+v,2);
sequence = gold;
M = 4; Nusers = 3;
for no = 1:Nusers
pn(no,:) = (-1).^sequence(no,:);
end;
h = zeros(1,M);
for path = 1:M
h(path) = randn+j*randn;
end;
err = [];
N = 100;
data = round(rand(N,Nusers));
err = cell(1);
nn = 1;
for i = 1:length(snr_in_dB)
[err_prob1 err_prob2] = errprob(data,snr_in_dB(i),M,pn,h);
end
% ----------------------------------------------------------------------- %
% Plot
err = err_prob1;
axes(handles.axes1)
err1 = err{1};
semilogy(snr_in_dB,err1,'r-+')
hold on
err2 = err{2};
semilogy(snr_in_dB,err2,'k-*')
hold on
err3 = err{3};
semilogy(snr_in_dB,err3,'g-+')
hold on
err4 = err{4};
semilogy(snr_in_dB,err4,'c-*')
hold off
axis([0 30 0.000001 1])
grid on
legend('M = 1 N = 512','M = 2 N = 256','M = 3 N = 128','M = 4 N = 64')
xlabel('Eb/No(dB)')
ylabel('Probability of Bit Error')
% *********************************************************************** %
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -