Effacer les filtres
Effacer les filtres

Restrict x values while plotting the pdf function

1 vue (au cours des 30 derniers jours)
Dhruwal Dilipbhai Bhimani
Dhruwal Dilipbhai Bhimani le 29 Oct 2021
Réponse apportée : KSSV le 29 Oct 2021
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.

Réponse acceptée

KSSV
KSSV le 29 Oct 2021
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')

Plus de réponses (0)

Catégories

En savoir plus sur Graphics Object Identification 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!

Translated by