I want to create a mesh from 2 plotted 1D PDF plots
2 次查看(过去 30 天)
显示 更早的评论
Dhruwal Dilipbhai Bhimani
2021-10-29
回答: Ashutosh Singh Baghel
2021-11-17
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
0 个评论
采纳的回答
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);
0 个评论
更多回答(0 个)
另请参阅
类别
在 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!