Plot the Bivariate Gaussian pdf

2 ビュー (過去 30 日間)
billyjthorton
billyjthorton 2018 年 9 月 15 日
回答済み: Jeff Miller 2018 年 9 月 16 日
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!

回答 (1 件)

Jeff Miller
Jeff Miller 2018 年 9 月 16 日
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