You should probably change x=0:1:8;
to something like x=0:1e-3:8;
or even x=linspace(0,8,1000);
to have finer plotting. This increases number of points in vectors (and therefore line segments) Matlab will use to plot.
Explanation: Matlab works with line segments when it does plotting!
By writing x=0:1:8;
you create vector [0 1 2 3 4 5 6 7 8]
that is of length 9, and by applying exppdf
and unifpdf
respectively you create two vectors of the same length derived from original vector. So basically you get vectors [exppdf(0) exppdf(1) ... exppdf(8)]
and [unifpdf(0) unifpdf(1) ... unifpdf(8)]
.
When you issue plot
command afterwards Matlab plots only line segments (8 of them in this case because there are 9 points):
- from (x(1), px_given_c1(1)) to (x(2), px_given_c1(2)),
- ...
- from (x(8), px_given_c1(8)) to (x(9), px_given_c1(9)).