I want to create a mesh from 2 plotted 1D PDF plots
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Dhruwal Dilipbhai Bhimani
el 29 de Oct. de 2021
Respondida: Ashutosh Singh Baghel
el 17 de Nov. de 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 comentarios
Respuesta aceptada
Ashutosh Singh Baghel
el 17 de Nov. de 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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Surface and Mesh Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!