Restrict x values while plotting the pdf function

2 次查看(过去 30 天)
mu2=3;
sigma2=2;
X2=normrnd(mu2,sigma2,[200,1]);
sorted_X2=sort(X2);
Y2=normpdf(sorted_X2,mu2,sigma2);
figure
plot(sorted_X2,Y2)
I am planning to plot the pdf function like attached figure where x values are random and I need not to include the negative x values as for the current problem thickness cannot be taken negative.

采纳的回答

KSSV
KSSV 2021-10-29
mu2=3;
sigma2=2;
X2=normrnd(mu2,sigma2,[200,1]);
sorted_X2=sort(X2);
Y2=normpdf(sorted_X2,mu2,sigma2);
figure
hold on
plot(sorted_X2,Y2,'r')
sorted_X2(sorted_X2<0) = 0 ;
plot(sorted_X2,Y2,'b')

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Interactive Control and Callbacks 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by