フィルターのクリア

How to plot 3D pdf without meshgrid

13 ビュー (過去 30 日間)
N/A
N/A 2020 年 3 月 11 日
コメント済み: N/A 2020 年 3 月 13 日
I need a 3D pdf plot without meshgrid.
I wrote this code but I don't know how to do it without meshgrid.
Can you help me please
mu=[0 1];
cov=[1 0.7; 0.7 2];
rng('default');
R = mvnrnd(mu,cov,10);
plot(R(:,1),R(:,2),'+');
x1 = -4:0.2:4;
x2 = -4:0.2:8;
[X1,X2] = meshgrid(x1,x2);
X = [X1(:) X2(:)];
y = mvnpdf(X,mu,cov);
y = reshape(y,length(x2),length(x1));
surf(x1,x2,y)
caxis([min(y(:))-0.5*range(y(:)),max(y(:))])
axis([-4 4 -4 8 0 0.15])
xlabel('x1')
ylabel('x2')
zlabel('Probability Density')

回答 (1 件)

darova
darova 2020 年 3 月 11 日
Without meshgrid
x = 1:3;
y = 1:4;
[X,Y] = meshgrid(x,y)
X1 = repmat(x,[length(y) 1])
Y1 = repmat(y(:),[1 length(x)])
Or you mean something else?
  1 件のコメント
N/A
N/A 2020 年 3 月 13 日
No, it doesn't give what I want. I need 3D surface as an output with my samples. Your code give just points.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by