Plot the Bivariate Gaussian pdf

2 vues (au cours des 30 derniers jours)
billyjthorton
billyjthorton le 15 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!

Réponses (1)

Jeff Miller
Jeff Miller le 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.

Community Treasure Hunt

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

Start Hunting!

Translated by