I want to create a mesh from 2 plotted 1D PDF plots
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Dhruwal Dilipbhai Bhimani
le 29 Oct 2021
Réponse apportée : Ashutosh Singh Baghel
le 17 Nov 2021
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 commentaires
Réponse acceptée
Ashutosh Singh Baghel
le 17 Nov 2021
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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Surface and Mesh Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!