資源簡介
基于MATLAB GUI通信系統仿真。本次電力系統通信技術的課程設計內容為基于MATLAB GUI的通信技術仿真平臺的搭建,該仿真平臺中可以根據不同的指令完成信源的產生、信道與噪聲的仿真、信號的調制與解調仿真、信源的編碼與解碼仿真和數字基帶傳輸系統眼圖和誤碼率的仿真等。
仿真平臺利用用MATLAB的GUI搭建:平臺以菜單方式工作,且平臺應包含上述內容中的所有模塊,系統可以顯示所有模塊應有相應的仿真結果及結果分析。本次課設設計了兩個平臺來進行通信系統的仿真,分別是2ASF隨機二進制信源調制解調誤碼率仿真系統以及PCM固定信源的編碼解碼。
代碼片段和文件信息
function?varargout?=untitled1(varargin)
gui_Singleton?=?1;
gui_State?=?struct(‘gui_Name‘???????mfilename?...
???????????????????‘gui_Singleton‘??gui_Singleton?...
???????????????????‘gui_OpeningFcn‘?@untitled1_OpeningFcn?...
???????????????????‘gui_OutputFcn‘??@untitled1_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
function?untitled1_OpeningFcn(hobject?eventdata?handles?varargin)
handles.output?=?hobject;
guidata(hobject?handles);
function?varargout?=?untitled1_OutputFcn(hobject?eventdata?handles)?
varargout{1}?=?handles.output;
function?pushbutton1_Callback(hobject?eventdata?handles)
global?I
global?fs
global?fb
global?fc
global?signal_in_one_bit
global?space_in_zero_bit
global?space_in_one_bit
global?y
global?S
global?signal
global?st
global?zs
global?f
global?df1
global?tz
global?nst
global?t
global?x
global?gjxs
global?d
x=round(rand(1I));%?產生信號比特
S=fs/fb;%?每比特采樣數
t=(0:S*I-1)/fs;
signal_in_one_bit=cos(2*pi*fc*(0:S*I-1)/fs);%載波
space_in_zero_bit=zeros(1S);?%為0時
space_in_one_bit=ones(1S)?;%為1時
y=zeros(1S*I)?;
for?i=1:length(x)
????if(x(i)==1)
????????y((i-1)*S+1:i*S)=space_in_one_bit;
????else
????????y((i-1)*S+1:i*S)=space_in_zero_bit;
????end
end
f=[0:df1:df1*(length(tz)-1)]-fs/2;%頻譜矢量計算
signal=y;
axes(handles.axes2);
plot(signal);
grid?on;
ylim([-2?2]);
st=y.*signal_in_one_bit;
disp(zs);
nst=awgn(stzs);
axes(handles.axes3);
grid?on;
plot(nst);
nst=nst.*signal_in_one_bit;
wp=2*pi*2*fc*0.5;
ws=2*pi*2*fc*0.9;
R=2;
T=45;
[N1wc]=buttord(wpwsRT‘s‘);
[BA]=butter(N1wc‘s‘);
h=tf(BA);
t=(0:S*I-1)/fs;
d=lsim(hnstt);
axes(handles.axes10);
grid?on;
plot(d);%濾波后的噪聲
%眼圖函數
Ts=1;
eyenum=10;
codenum=2000;
tsample=4;
dt=0.2;
t=-eyenum/2:dt:eyenum/2;
if?isempty(gjxs)
gjxs=1;
end
pp=cos(gjxs*pi*t/Ts);
pp1=1./(1-4*t.*t*gjxs*gjxs/Ts/Ts);
ht=1/Ts*sinc(t/Ts).*pp.*pp1;
code=sign(randn(1codenum))+0.05*randn(1codenum);%畫眼圖
for?n=1:codenum/eyenum
????ss=zeros(1length(ht)+Ts/dt);
????for?m=1:eyenum
????????tmp=code((n-1)*eyenum+m)*ht;
????????tmp1=ss((m*Ts/dt+1):length(ss))+tmp;
????????ss?=[ss(1:(m*Ts/dt))?tmp1?zeros(1Ts/dt)];
????end
????drawnow
????kk=1:length(ss);
????axes(handles.axes7);
????plot(kk*dt-dtss);hold?on
????clear?ss;
????axis([5?15?-3?3]);
end
function?edit1_Callback(hobject?eventdata?handles)
global?fs
fs=str2double(get(findobj(‘Tag‘‘edit1‘)‘String‘?));?%采樣頻率
function?edit1_CreateFcn(hobject?eventdata?handles)
if?ispc?&&?isequal(get(hobject‘BackgroundColor‘)?get(0‘defaultUicontrolBackgroundColor‘))
????set(hobject‘BackgroundColor‘‘white‘);
end
function?edit2_Callback(hobject?eventdata?handles)
global?I
I=str2double(get(findobj(‘Tag‘‘edit2‘)‘String‘));?%周期點數
function?edit2_CreateFcn(hobject?eventdata?handles)
if?ispc?&&?is
- 上一篇:數字圖像處理DSP_IIR帶通濾波器的設計
- 下一篇:高分辨率數字圖像加密算法
評論
共有 條評論