{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Lecture.04.Homework_Solutions

# Lecture.04.Homework_Solutions - return end[a b]=find(s1~=s2...

This preview shows pages 1–3. Sign up to view the full content.

Homework II Solutions 1) M=[2 4 8]; SNRdB=-6:2:20; SNR=10.^(SNRdB./10); for i=1:3 Perror(i,:) = (M(1,i)-1)./M(1,i).*erfc(sqrt(3.*log2(M(1,i))*SNR./(M(1,i).^2-1))); end semilogy(SNRdB, Perror(1,:), '+-' ); hold on ; semilogy(SNRdB, Perror(2,:), '-<' ); semilogy(SNRdB, Perror(3,:), 'o-' ); grid on ; axis([-6 20 10^(-6) 10^(-1)]); legend( 'M=2' , 'M=4' , 'M=8' ); xlabel( 'SNR(dB) per bit' ); ylabel( 'Probability of a symbol error, P_{M}' ); 2) function H_dis= myfunction(s1,s2) if (nargin~=2) error('The number of input strings should equal to 2') return end if (size(s1,1)~=size(s2,1) |size(s1,2)~=size(s2,2)) error('The size of the inputs are different') return end check1 = sum(find(s1~=0&s1~=1)); check2 = sum(find(s2~=0&s2~=1)); if (check1~=0 | check2~=0) error('The strings should consists of 0s and 1s')

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: return end [a b]=find(s1~=s2); H_dist = sum(a) 3) function [m,v]=mean_variance(s1,s2) if (nargin == 1&& nargout ==2) m = mean(s1); v = var(s1); elseif (nargin == 1&& nargout ==1) m = mean([s1]); elseif (nargin == 2&& nargout ==1) s_con = [s1 s2]; m = mean(s_con); elseif (nargin == 2&& nargout ==2) s_con = [s1 s2]; m = mean(s_con); v = var(s_con); end 4) clear all; close all; tic x=0:pi/10000:pi; for(i=1:size(x,2)) y(i)=sin(x(i)^3)+cos(x(i))+x(i)^2; end toc clear all; close all; tic x=0:pi/10000:pi; y=zeros(size(x)); for(i=1:size(x,2)) y(i)=sin(x(i)^3)+cos(x(i))+x(i)^2; end toc clear all; close all; tic x=0:pi/10000:pi; y=sin(x.^3)+cos(x)+x.^2; toc clear all; close all; tic x=0:pi/10000:pi; y=zeros(size(x)); y=sin(x.^3)+cos(x)+x.^2; toc...
View Full Document

{[ snackBarMessage ]}

### Page1 / 3

Lecture.04.Homework_Solutions - return end[a b]=find(s1~=s2...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online