3D Plot of Probability Density Functions using normpdf and line function
3 ビュー (過去 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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/856885/image.jpeg)
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!