help me in understanding the code

clear,
clc;
pdf='exp(-(x-m).^2/2/sigma^2)/sqrt(2*pi)/sigma'; %Gaussian pdf of x
xf=inline(['x.*' pdf],'x','m','sigma');
f=inline(pdf,'x','m','sigma');
m=0; sigma=1; % Mean and variance of the random variable x
b0=-3; bN=3; % Given least/greatest value of the random variable x
for N=5:6 % Number of quantization intervals
delta=(bN-b0)/N;
b=b0+[0:N]*delta;
msqe=0; % Mean-Square Quantization Error
for i=1:N % Centroid of each interval
tmp1=quad(xf,b(i),b(i+1),0.01,[],m,sigma);
tmp2=quad(f,b(i),b(i+1),0.01,[],m,sigma);
tmp=tmp1/tmp2; c(i)=tmp; % Eq.(4.1.1)
x2f=inline(['(x-tmp).^2.*' pdf],'x','m','sigma','tmp');
msqe=msqe+quad(x2f,b(i),b(i+1),0.01,[],m,sigma,tmp); % Eq.(4.1.2)
end
% Resulting boundary vector and centroid vector
x=b0+(bN-b0)/1000*[0:1000];
y(find(x<b(1)))=c(1); % Left-most interval
for i=1:N, y(find(b(i)<=x&x<b(i+1)))=c(i); end
y(find(x>=b(N+1)))=c(N); % Right-most interval
subplot(2,2,N-4),
plot(x,y),
hold on,
grid on % Quantization graph
m=0; sigma=1; fx=feval(f,x,m,sigma);
plot(x,fx,'r:') ;
% Resulting MSQE
end

댓글 수: 2

Walter Roberson
Walter Roberson 2012년 4월 15일
Please be more specific in your question. For example are you stuck at the "clc" call, or are you stuck on logical indexing, or are you stuck in understanding what the [] argument to quad() means?
Rick Rosson
Rick Rosson 2012년 4월 15일
Help us by asking a specific question.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기

태그

질문:

2012년 4월 15일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by