3D Plot of Probability Density Functions using normpdf and line function
7 次查看(过去 30 天)
显示 更早的评论
I am trying to plot consecutive PDFs(Probability Density Function) using the line function in a 3D plot. I am able to plot the PDFs in 2D plot. However, may I please get some corrections/suggestions for the following code for the 3D plot. I am trying to show peak probability on vertical axis for t iterations.Thank you.
sigma = 30;
mu = 230;
t = 5;
for i = 1:1:t
if mu <= 230*5
s6=6*sigma;
x_pdf_1 = [-700:700];
y1 = normpdf(x_pdf_1,mu,sigma);
figure(1)
hold on
l=line(x_pdf_1,y1);
figure(2)
plot3(l,mu,t)
mu = mu+30;
end
end
2D Plot Result
0 个评论
回答(1 个)
Prahlad Gowtham Katte
2022-1-25
Hi
I understand that you’re trying to plot consecutive PDFs using 3D plot. Following code snippet might help to resolve the issue.
sigma = 30;
mu = 230;
t = 5;
for i = 1:1:t
if mu <= 230*5
s6=6*sigma;
x_pdf_1 = [-700:700];
y1 = normpdf(x_pdf_1,mu,sigma);
figure(1)
hold on
l=line(x_pdf_1,y1);
figure(2)
plot3(x_pdf_1,y1,i*(ones(length(x_pdf_1)))) %Plotting a 3d plot in iteration i.
hold on %Making sure the plots would be on same figure
mu = mu+30;
end
end
The following link might give you a more detailed explanation of 3D plots.
Hope it answers your query.
Thanks
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!