필터 지우기
필터 지우기

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 CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by