声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1120|回复: 1

求教大哥们~~帮小弟解答下matlab通信仿真关于GUI的问题

[复制链接]
发表于 2006-6-12 20:41 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
<v:shapetype>
<P ><B >关于最佳基带系统的误码率分析模型<p></p></B></P>
<P ><v:shapetype><v:stroke joinstyle="miter"></v:stroke><v:formulas><v:f eqn="if lineDrawn pixelLineWidth 0"></v:f><v:f eqn="sum @0 1 0"></v:f><v:f eqn="sum 0 0 @1"></v:f><v:f eqn="prod @2 1 2"></v:f><v:f eqn="prod @3 21600 pixelWidth"></v:f><v:f eqn="prod @3 21600 pixelHeight"></v:f><v:f eqn="sum @0 0 1"></v:f><v:f eqn="prod @6 1 2"></v:f><v:f eqn="prod @7 21600 pixelWidth"></v:f><v:f eqn="sum @8 21600 0"></v:f><v:f eqn="prod @7 21600 pixelHeight"></v:f><v:f eqn="sum @10 21600 0"></v:f></v:formulas><v:path connecttype="rect" gradientshapeok="t" extrusionok="f"></v:path><lock aspectratio="t" v:ext="edit"></lock></v:shapetype></P>
<P ><FONT face="Times New Roman">(</FONT>一<FONT face="Times New Roman">)</FONT>,用到的函数<p></p></P>
<P ><FONT face="Times New Roman">1</FONT>、<FONT face="Times New Roman">f2t</FONT>函数<p></p></P>
<P ><FONT face="Times New Roman">   function x=f2t(X)<p></p></FONT></P>
<P ><FONT face="Times New Roman">global dt df t f T N<p></p></FONT></P>
<P ><FONT face="Times New Roman">%x=f2t(X)<p></p></FONT></P>
<P ><FONT face="Times New Roman">%x</FONT>为时域的取样值矢量<p></p></P>
<P ><FONT face="Times New Roman">%X</FONT>为<FONT face="Times New Roman">x</FONT>的傅氏变换<p></p></P>
<P ><FONT face="Times New Roman">%X</FONT>与<FONT face="Times New Roman">x</FONT>长度相同并为<FONT face="Times New Roman">2</FONT>的整幂<p></p></P>
<P ><FONT face="Times New Roman">%</FONT>本函数需要一个全局变量<FONT face="Times New Roman">dt(</FONT>时域取样间隔<FONT face="Times New Roman">)<p></p></FONT></P>
<P ><FONT face="Times New Roman">X=[X(N/2+1:N),X(1:N/2)];<p></p></FONT></P>
<P ><FONT face="Times New Roman">x=ifft(X)/dt;<p></p></FONT></P>
<P ><FONT face="Times New Roman">end<p></p></FONT></P>
<P ><FONT face="Times New Roman">2</FONT>、<FONT face="Times New Roman">t<st1:chmetcnv w:st="on" TCSC="0" NumberType="1" Negative="False" HasSpace="False" SourceValue="2" UnitName="F">2f</st1:chmetcnv></FONT>函数<p></p></P>
<P ><FONT face="Times New Roman">function X=t<st1:chmetcnv w:st="on" TCSC="0" NumberType="1" Negative="False" HasSpace="False" SourceValue="2" UnitName="F">2f</st1:chmetcnv>(x)<p></p></FONT></P>
<P ><FONT face="Times New Roman">global dt df N t f T<p></p></FONT></P>
<P ><FONT face="Times New Roman">%X=t<st1:chmetcnv w:st="on" TCSC="0" NumberType="1" Negative="False" HasSpace="False" SourceValue="2" UnitName="F">2f</st1:chmetcnv>(x)<p></p></FONT></P>
<P ><FONT face="Times New Roman">%x</FONT>为时<FONT face="Times New Roman">0</FONT>域的取样值矢量<p></p></P>
<P ><FONT face="Times New Roman">%X</FONT>为<FONT face="Times New Roman">x</FONT>的傅氏变换<p></p></P>
<P ><FONT face="Times New Roman">%X</FONT>与<FONT face="Times New Roman">x</FONT>长度相同<FONT face="Times New Roman">,</FONT>并为<FONT face="Times New Roman">2</FONT>的整幂。<p></p></P>
<P ><FONT face="Times New Roman">%</FONT>本函数需要一个全局变量<FONT face="Times New Roman">dt(</FONT>时域取样间隔<FONT face="Times New Roman">)<p></p></FONT></P>
<P ><FONT face="Times New Roman">H=fft(x);<p></p></FONT></P>
<P ><FONT face="Times New Roman">X=[H(N/2+1:N),H(1:N/2)]*dt;<p></p></FONT></P>
<P ><FONT face="Times New Roman">end<p></p></FONT></P>
<P ><FONT face="Times New Roman">(</FONT>二<FONT face="Times New Roman">),</FONT>主程序<p></p></P>
<P ><FONT face="Times New Roman">%</FONT>本程序中时间单位是<FONT face="Times New Roman">us<p></p></FONT></P>
<P ><FONT face="Times New Roman">%</FONT>频率单位为<FONT face="Times New Roman">MHZ<p></p></FONT></P>
<P ><FONT face="Times New Roman">%</FONT>码速率单位是<FONT face="Times New Roman">Mb/s<p></p></FONT></P>
<P ><FONT face="Times New Roman">global dt df t f N T<p></p></FONT></P>
<P ><FONT face="Times New Roman">close all<p></p></FONT></P>
<P ><FONT face="Times New Roman">clear Eb_N0 Pe<p></p></FONT></P>
<P ><FONT face="Times New Roman"> N=2^13;       %</FONT>采样点数<p></p></P>
<P ><FONT face="Times New Roman"> L=8;       %</FONT>每个码元的采样点数<p></p></P>
<P ><FONT face="Times New Roman"> M=N/L;      %</FONT>码元数<p></p></P>
<P ><FONT face="Times New Roman"> Rb=2;       %</FONT>码速率是<FONT face="Times New Roman">2MB/s<p></p></FONT></P>
<P ><FONT face="Times New Roman"> Ts=1/Rb;    %</FONT>码元间隔<p></p></P>
<P ><FONT face="Times New Roman"> dt=Ts/L;    %</FONT>时域采样间隔<p></p></P>
<P ><FONT face="Times New Roman"> df=1/(N*dt);    %</FONT>频域采样间隔<p></p></P>
<P ><FONT face="Times New Roman"> T=N*dt;     %</FONT>截短时间<p></p></P>
<P ><FONT face="Times New Roman"> Bs=N*df/2    %</FONT>系统带宽<p></p></P>
<P ><FONT face="Times New Roman"> alpha=1;<p></p></FONT></P>
<P ><FONT face="Times New Roman"> t=linspace(-T/2,T/2,N);<p></p></FONT></P>
<P ><FONT face="Times New Roman"> f=linspace(-Bs,Bs,N)+eps;%eps</FONT>为了避免<FONT face="Times New Roman">f=0;<p></p></FONT></P>
<P ><FONT face="Times New Roman"> figure(1)<p></p></FONT></P>
<P ><FONT face="Times New Roman"> set(1,'position',[10,50,500,500])<p></p></FONT></P>
<P ><FONT face="Times New Roman">  hr1=sin(pi.*t/Ts)./(pi.*t/Ts);<p></p></FONT></P>
<P ><FONT face="Times New Roman">  hr2=cos(alpha*pi.*t/Ts)./(1-(2*alpha.*t/Ts).^2);<p></p></FONT></P>
<P ><FONT face="Times New Roman">  hr=hr1.*hr2;             %</FONT>升余弦脉冲波形<p></p></P>
<P ><FONT face="Times New Roman">  HR=abs(t2f(hr));        %</FONT>取模是为了忽略时延<p></p></P>
<P ><FONT face="Times New Roman">  GT=sqrt(HR);<p></p></FONT></P>
<P ><FONT face="Times New Roman">  GR=GT;<p></p></FONT></P>
<P ><FONT face="Times New Roman">  for loop1=1:10<p></p></FONT></P>
<P ><FONT face="Times New Roman">      Eb_N0(loop1)=(loop1-1)<p></p></FONT></P>
<P ><FONT face="Times New Roman">      eb_n0(loop1)=10^(Eb_N0(loop1)/10);<p></p></FONT></P>
<P ><FONT face="Times New Roman">     <FONT color=#e6e61a> </FONT></FONT><FONT color=#e6e61a>Eb=1;<p></p></FONT></P>
<P ><FONT face="Times New Roman">      n0=Eb/eb_n0(loop1);%</FONT>信道的噪声谱密度<p></p></P>
<P ><FONT face="Times New Roman">      sita=n0*Bs;    %</FONT>信道中噪声功率<p></p></P>
<P ><FONT face="Times New Roman">      n_err=0;    %</FONT>误码计数<p></p></P>
<P ><FONT face="Times New Roman">    for loop2=1:5<p></p></FONT></P>
<P ><FONT face="Times New Roman">    a=sign(randn(1,M));<p></p></FONT></P>
<P ><FONT face="Times New Roman">    imp=zeros(1,N);<p></p></FONT></P>
<P ><FONT face="Times New Roman">    imp(L/2:L:N)=a/dt;  %</FONT>产生冲激序列<p></p></P>
<P ><FONT face="Times New Roman">    IMP=t2f(imp);<p></p></FONT></P>
<P ><FONT face="Times New Roman">    n_ch=sqrt(sita)*randn(size(t));%</FONT>信道噪声<p></p></P>
<P ><FONT face="Times New Roman">    nr=real(f2t(t2f(n_ch).*GR));  %</FONT>输出噪声<p></p></P>
<P ><FONT face="Times New Roman">    sr=real(f2t(IMP.*HR))+nr;    <p></p></FONT></P>
<P ><FONT face="Times New Roman">    y=sr(L/2:L:N);              <p></p></FONT></P>
<P ><FONT face="Times New Roman">    aa=sign(y);                     %</FONT>判决<p></p></P>
<P ><FONT face="Times New Roman">    n_err=n_err+length(find(aa~=a));<p></p></FONT></P>
<P ><FONT face="Times New Roman">end<p></p></FONT></P>
<P ><FONT face="Times New Roman">pe(loop1)=n_err/(M*loop2)<p></p></FONT></P>
<P ><FONT face="Times New Roman">figure(1)<p></p></FONT></P>
<P ><FONT face="Times New Roman"> semilogy(Eb_N0,pe,'r');<p></p></FONT></P>
<P ><FONT face="Times New Roman"> eb_n0=10.^(Eb_N0/10);<p></p></FONT></P>
<P ><FONT face="Times New Roman"> hold on<p></p></FONT></P>
<P ><FONT face="Times New Roman"> semilogy(Eb_N0,0.5*erfc(sqrt(eb_n0)));<p></p></FONT></P>
<P ><FONT face="Times New Roman"> axis([0,9,1e-4,1])<p></p></FONT></P>
<P ><FONT face="Times New Roman">title('</FONT>最佳接收基带接收系统的误码率分析<FONT face="Times New Roman">')<p></p></FONT></P>
<P ><FONT face="Times New Roman"> Xlabel('Eb/N0')<p></p></FONT></P>
<P ><FONT face="Times New Roman"> Ylabel('Pe')<p></p></FONT></P>
<P ><FONT face="Times New Roman">End<BR>请教大哥们~怎么将上面的程序通过GUI制作成一个可以通过改变Eb的数值从而改变Pe与Eb/N0图形的分析模型<BR>小弟感激不尽~~请各位大哥们指教指教!!!谢谢<BR></FONT></v:shapetype></P>
回复
分享到:

使用道具 举报

 楼主| 发表于 2006-6-13 12:53 | 显示全部楼层
或者请高手帮我把上面主程序改成<FONT face="Times New Roman">function定义的关于Eb的函数文件。。。<BR>像上面的f2t、t2f函数那样子d ~~ 期待各位大哥指导!先谢谢了</FONT>
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-11-12 20:37 , Processed in 0.057392 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表