MATLAB Answers

0

Plot the Bivariate Gaussian pdf

Asked by billyjthorton on 15 Sep 2018
Latest activity Answered by Jeff Miller on 16 Sep 2018
I'm trying to plot the Bivariate Gaussian pdf with zero mean and covariance (6, 2; 2,2), but I'm coming up with a weird error. Here is my code:
figure
mu = 0
covariance = [6 2; 2 2]
norm = normpdf(R,mu,covariance)
plot(R,norm)
But I get this as an error:
Error using normpdf (line 36)
Non-scalar arguments must match in size.
How can I properly plot the pdf with the specified covariance? As a side note, the variable R comes from a earlier established normal variable with mean of 5 and variance of 30 (randn(5, 30))
Thanks for your time and help in advanced! I really appreciate it!

  0 Comments

Sign in to comment.

1 Answer

Answer by Jeff Miller on 16 Sep 2018

normpdf is the univariate normal pdf. You need mvnpdf, which is the multivariate version. Also, plot will not produce a 3d plot. See multivariate normal . The first example seems pretty close to what you want.

  0 Comments

Sign in to comment.