How to plot 3D pdf without meshgrid
조회 수: 13 (최근 30일)
이전 댓글 표시
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')
댓글 수: 0
답변 (1개)
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?
참고 항목
카테고리
Help Center 및 File Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!