Personal tools
  •  

MinDistReceiver

Document Actions
  • Bookmarks
  • CourseFeed

Click here to get the file

Size 2.3 kB - File type text/plain

File contents

             clf;
nstd = 0.1;

syms = [1 1 -1 -1]+j*[1 -1 1 -1];
syms = syms/sqrt(2);

t=2*pi*[0:100]/100;
z = zeros(size(t));

n = randn(3,1);
n(1:2) = nstd*n(1:2);
n(3) = abs(2*n(3));
i=1;
subplot(121);
rhan(1)=plot3([0,real(syms(i))+n(1)],[0,imag(syms(i))+n(2)],[0,n(3)],'k');
hold on;
rhan(2)=plot3([0,real(syms(i))+n(1)],[0,imag(syms(i))+n(2)],[0,0],'k');
rhan(3)=plot3((real(syms(i))+n(1))*[1 1],(imag(syms(i))+n(2))*[1 1],[0,n(3)],'k');
plot3([-2 -2 2 2 -2],[-2 2 2 -2 -2],zeros(5,1),'k');
axis([-2 2 -2 2 -2 2]);
for i=1:length(syms)
  han(i)=plot3(0.05*cos(t)+real(syms(i)),0.05*sin(t)+imag(syms(i)),z,'b');
  set(han(i),'EraseMode','xor');  
end
plot3(cos(t),sin(t),zeros(size(t)),':k');
hold on;

subplot(122);
lhan(1)=plot([0,real(syms(i))+n(1)],[0,imag(syms(i))+n(2)],'k');
hold on;
lhan(2)=plot([0,real(syms(i))+n(1)],[0,imag(syms(i))+n(2)],'k');
lhan(3)=plot((real(syms(i))+n(1))*[1 1],(imag(syms(i))+n(2))*[1 1],'k');
axis([-2 2 -2 2]); axis('square');
for i=1:length(syms)
  hanl(i)=plot(0.05*cos(t)+real(syms(i)),0.05*sin(t)+imag(syms(i)),'b');
  set(hanl(i),'EraseMode','xor');  
end
plot(cos(t),sin(t),':k');
hold on;

for iter=1:2000
n = randn(3,1);
n(1:2) = nstd*n(1:2);
n(3) = abs(2*n(3));
i = floor(4*rand(1,1))+1;
set(han(i),'Color',[1 0 0]);
set(hanl(i),'Color',[1 0 0]);
rvec = syms(i) + (n(1)+j*n(2));
[themax,imax]=max(real(rvec*syms'));

set(rhan(3),'XData',(real(syms(i))+n(1))*[1 1]);
set(rhan(3),'YData',(imag(syms(i))+n(2))*[1 1]);
set(rhan(3),'ZData',[0 n(3)]);
set(rhan(2),'XData',[0,real(syms(i))+n(1)]);
set(rhan(2),'YData',[0,imag(syms(i))+n(2)]);
set(rhan(1),'XData',[0,real(syms(i))+n(1)]);
set(rhan(1),'YData',[0,imag(syms(i))+n(2)]);
set(rhan(1),'ZData',[0 n(3)]);

set(lhan(3),'XData',(real(syms(i))+n(1))*[1 1]);
set(lhan(3),'YData',(imag(syms(i))+n(2))*[1 1]);
set(lhan(2),'XData',[0,real(syms(i))+n(1)]);
set(lhan(2),'YData',[0,imag(syms(i))+n(2)]);
set(lhan(1),'XData',[0,real(syms(i))+n(1)]);
set(lhan(1),'YData',[0,imag(syms(i))+n(2)]);

if(imax == i)
  plot3(real(syms(i))+n(1),imag(syms(i))+n(2),0,'.r'); hold on;
  plot(real(syms(i))+n(1),imag(syms(i))+n(2),'.r'); hold on;
else
  plot3(real(syms(i))+n(1),imag(syms(i))+n(2),0,'xk'); hold on;
  plot(real(syms(i))+n(1),imag(syms(i))+n(2),'xk'); hold on;
end


pause;
set(han(i),'Color',[0 0 1]);
set(hanl(i),'Color',[0 0 1]);
end
subplot(121); hold off;
subplot(122); hold off;
            
Copyright 2008, by the Contributing Authors. Cite/attribute Resource . admin. (2006, June 28). MinDistReceiver. Retrieved January 07, 2011, from Free Online Course Materials — USU OpenCourseWare Web site: http://ocw.usu.edu/Electrical_and_Computer_Engineering/Communication_Systems_I/mindistreceiver.m-view.html. This work is licensed under a Creative Commons License Creative Commons License