patch_opt_rule.m
Size 2.0 kB - File type text/plainFile contents
C = [1 1; 1 -1; -1 1; -1 -1];
N0 = 0.5;
r0 = 1/3;
rvec = [-3:r0:3];
[r1,r2]=meshgrid(rvec,rvec);
% Show constellation and grid
figure(1); clf;
han=plot(C(:,1),C(:,2),'ob','LineWidth',2);
axis([r1(1) r1(end) r2(1) r2(end)]);
hold on;
for i=r1(1):r0:r1(end)
plot([i i],[r2(1),r2(end)],':k');
plot([r2(1),r2(end)],[i i],':k');
end
plot([0 0],[r2(1) r2(end)],'k');
plot([r1(1) r1(end)],[0 0],'k');
hold off;
axis('equal');
axis('tight');
%print -djpeg95 -r75 constellation.jpg
pause;
% Show noise distribution
figure(1); clf;
r0 = 1/15;
rvec = [-3:r0:3];
[r1,r2]=meshgrid(rvec,rvec);
pn = exp(-(r1.^2 + r2.^2)/N0)/(pi*N0);
surf(rvec,rvec,pn);
%print -djpeg95 -r75 pn_surf.jpg
pause;
clf;
contour(rvec,rvec,pn,20);
hold on;
plot([0 0],[r2(1) r2(end)],'k');
plot([r1(1) r1(end)],[0 0],'k');
hold off;
axis('equal');
axis('tight');
%print -djpeg95 -r75 pn_contour.jpg
pause;
% Show likelihood functions
figure(1); clf;
han=plot(C(:,1),C(:,2),'ob','LineWidth',2);
axis([r1(1) r1(end) r2(1) r2(end)]);
for i=1:size(C,1)
subplot(2,2,i);
han=plot(C(:,1),C(:,2),'ob','LineWidth',2);
axis([r1(1) r1(end) r2(1) r2(end)]);
hold on;
pn = exp(-((r1-C(i,1)).^2 + (r2-C(i,2)).^2)/N0)/(pi*N0);
contour(rvec,rvec,pn,20);
plot([0 0],[r2(1) r2(end)],'k');
plot([r1(1) r1(end)],[0 0],'k');
hold off;
axis('equal');
axis('tight');
end
%print -djpeg95 -r75 like.jpg
pause;
% Show infinitesimal patch
clf;
pat = [0.5 0.6; 0.6 0.6; 0.6 0.7; 0.5 0.7];
han=plot(C(:,1),C(:,2),'ob','LineWidth',2);
axis([r1(1) r1(end) r2(1) r2(end)]);
hold on;
for i=1:size(C,1)
pn = exp(-((r1-C(i,1)).^2 + (r2-C(i,2)).^2)/N0)/(pi*N0);
contour(rvec,rvec,pn,20);
end
plot([0 0],[r2(1) r2(end)],'k');
plot([r1(1) r1(end)],[0 0],'k');
axis('equal');
axis('tight');
patch(pat(:,1),pat(:,2),'k');
hold off;
%print -djpeg95 -r75 patch1.jpg
pause;
clf;
pn = zeros(size(C,1),size(C,1));
for i=1:size(C,1)
for j=1:size(C,1)
pn(i,j) = exp(-(pat(i,1)^2+pat(i,2)^2)/N0)/(pi*N0);
end
end
for i=1:size(C,1)
patch(pat(:,1),pat(:,2),pn(i,:).','c');
hold on;
end
hold off;
grid on;
%print -djpeg95 -r75 patch2.jpg
Copyright 2008,
by the Contributing Authors.
Cite/attribute Resource.
admin. (2006, June 28). patch_opt_rule.m. Retrieved October 12, 2008, from Free Online Course Materials — USU OpenCourseWare Web site: http://ocw.usu.edu/Electrical_and_Computer_Engineering/Communication_Systems_I/patch_opt_rule.m.
This work is licensed under a
Creative Commons License.


















Click here to get the file
