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

📄 parta.m

📁 number of symbols to be generated
💻 M
字号:
 % Solves parts A and C  % April 26, 1999% Developed by Ali H. Sayed  close allclear all var_v=0.004;  % (25dB SNR)   % variance of noise; CAN BE CHANGED %var_v=0.05;  % (14dB SNR)N=2000;          % number of symbols to be generated   s=sign(randn(1,N));           % generates BPSK data y=filter([1 0.5],1,s);        % Filters the data through the channel y=y+sqrt(var_v)*randn(1,N);   % adds noise to it    % We form the covariance matrix R_y % Its (1,1) entry is kept in terms of the noise % variance for generality  Ry=[((5/4)+var_v) 1/2   0      1/2  ((5/4)+var_v)  1/2     0   1/2    ((5/4)+var_v)];    Ryinv=inv(Ry);     %%%% We plot the scatter diagrams of %%%% both the transmitted and received signals  subplot(221); plot(s,'x');grid; title('Transmitted sequence s(i)'); xlabel('i');   subplot(222); plot(y,'x');grid; title('Received sequence y(i)'); xlabel('i');  subplot(223); plot(real(s),imag(s),'x');grid; title('Transmitted sequence s(i)');   subplot(224); plot(real(y),imag(y),'x');grid; title('Received sequence y(i)');   for Delta=0:3    % three values of Delta    % The value of Rxy depends on the choice of Delta     switch Delta     case 0, Rxy = [1 0 0];     case 1, Rxy = [0.5 1 0];     case 2, Rxy = [0 0.5 1];     case 3, Rxy = [0 0 0.5];     end          Ko = Rxy*Ryinv;       % Optimal equalizer     s_hat=filter(Ko,1,y); % Filter y(i) through equalizer                          % to generate hat{s}(i-Delta)              figure     subplot(222);      plot(s_hat,'x');grid;      title(['Equalizer output for \Delta=',num2str(Delta)]);      xlabel('i');        subplot(221);      plot(y,'x');grid;      title('Received sequence y(i)');      xlabel('i');           subplot(224);      plot(real(s_hat),imag(s_hat),'x');grid;      title(['Equalizer output for \Delta=',num2str(Delta)]);        subplot(223);      plot(real(y),imag(y),'x');grid;      title('Received sequence y(i)');          % Estimate of m.m.s.e.      ind_1=(1:N-Delta) + Delta;     ind_2=1:N-Delta;      mmse(Delta+1)=sum((s_hat(ind_1)-s(ind_2)).*(s_hat(ind_1)-s(ind_2)));     mmse(Delta+1)=mmse(Delta+1)/(N-Delta);         % Number of errors        num_error(Delta+1)=0;      s_nl=zeros(1,N);           for j=1:N-Delta         s_nl(j)=sign(s_hat(j+Delta));  %Output of decision device        if s_nl(j)==0          s_nl(j)=1;        end         if abs(s_nl(j)-s(j)) > 0.1          num_error(Delta+1) = num_error(Delta+1)+1;        end      end     Ko end  figure subplot(221); stem(0:3,mmse); grid; title('MMSE'); xlabel('\Delta'); ylabel('mmse'); subplot(222); stem(0:3,num_error); grid; title('Number of errors'); xlabel('\Delta'); ylabel('errors');  num_error

⌨️ 快捷键说明

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