Info

This question is closed. Reopen it to edit or answer.

Why does changing y in my conditional density function f(x|y) not change my results?

1 view (last 30 days)
My assignment is to make plots of fx(x|y) for the cases y = {-5 0 5 10 15 20}. The conditional pdf is the result of a signal x going through gaussian noise n and coming out to the receiver y = x + n. When I run my code which I provided below with different values for y or yi in my program the plot never changes. Can anyone see what I'm doing wrong?
yi = -5;
F = zeros (1, 102);
e = repmat(2.71,1,51);
X1 = 0:0.1:5;
X2 = 5:0.1:10;
X = 0:0.1:10.1;
Fa = (X1/25) * (1/sqrt(8*3.14));
Fb = (2/5 - (X1/25)) * (1/sqrt(8*3.14));
P1 = (e.^((-1 * (yi-X1))/8));
P2 = (e.^((-1 * (yi-X2))/8));
F1 = Fa .* P1;
F2 = Fb .* P2;
k1 = trapz(X1,F1);
k2 = trapz(X2,F2);
F1 = F1 * (1/k1);
F2 = F2 * (1/k2);
j = 1;
while(j<=102)
if j <= 51
F(1,j) = F1(1,j);
else %f(x|y)
F(1,j) = F2(1,j-51);
end
j = j + 1;
end
figure(1)
plot(X,F); %plot of f(x|y) vs x

Answers (0)

Community Treasure Hunt

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

Start Hunting!