필터 지우기
필터 지우기

I want to create a mesh from 2 plotted 1D PDF plots

조회 수: 1 (최근 30일)
I want to create a mesh given the two one dimensional pdf plot whose code is as follows:
mu1=3.4*10^6;
sigma1=0.5*10^6;
X1=normrnd(mu1,sigma1,[200,1]);
sorted_X1=sort(X1);
Y1=normpdf(sorted_X1,mu1,sigma1);
figure
plot(sorted_X1,Y1)
mu2=3;
sigma2=2;
X2=normrnd(mu2,sigma2,[200,1]);
sorted_X2=sort(X2);
Y2=normpdf(sorted_X2,mu2,sigma2);
prior_deltau=zeros(200,1);
for i=1:200
if sorted_X2(i)<=0
prior_deltau(i)=0;
else
prior_deltau(i)=Y2(i);
end
end
figure
plot(sorted_X2,prior_deltau)
With X2 on x-axis and Y2 on y-axis

채택된 답변

Ashutosh Singh Baghel
Ashutosh Singh Baghel 2021년 11월 17일
Hi Dhruwal,
I understand you wish to plot a 3d mesh with the vectors 'prior_deltaa' and 'Y1' as y-coordinates of points when 'sorted_X2' and 'sortedX1' are x-coordinates of points, respectively. To resolve this issue, the following is one approach -
mu1=3.4*10^6;
sigma1=0.5*10^6;
X1=normrnd(mu1,sigma1,[200,1]);
sorted_X1=sort(X1);
Y1=normpdf(sorted_X1,mu1,sigma1);
% figure
% plot(sorted_X1,Y1)
mu2=3;
sigma2=2;
X2=normrnd(mu2,sigma2,[200,1]);
sorted_X2=sort(X2);
Y2=normpdf(sorted_X2,mu2,sigma2);
prior_deltau=zeros(200,1);
for i=1:200
if sorted_X2(i)<=0
prior_deltau(i)=0;
else
prior_deltau(i)=Y2(i);
end
end
% figure
% plot(sorted_X2,prior_deltau)
[X,Y] = meshgrid(sorted_X2,sorted_X1);
Z = Y1*prior_deltau';
mesh(X,Y,Z);
Refer to the following MATLAB Documentation page on 'meshgrid' and 'mesh'.

추가 답변 (0개)

카테고리

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