how can I change the code to have only unique CDF and PDF plot?not for all samples
2 ビュー (過去 30 日間)
古いコメントを表示
mu = 1;
sigma = 5; % make the distribution as wide as we want.
N = 100;
randgeneration = randn(N,1)*sigma + mu;
pdfNormal = normpdf(randgeneration, mu, sigma);
figure;
subplot(2,2,1)
plot(randgeneration, pdfNormal);
xlabel('randomgeneration');
ylabel('pdfNormal');
subplot(2,2,2)
histogram(randgeneration);
subplot(2,2,3)
histfit(randgeneration);
subplot(2,2,4);
pd=makedist('Normal'); %create probability distribution object
cumulativedis=cdf(pd,randgeneration);
plot(randgeneration,cumulativedis,'r-.');
xlabel('randgeneration');
ylabel('CDF');
disp(mean(randgeneration));
disp(std(randgeneration))
0 件のコメント
採用された回答
Star Strider
2022 年 5 月 16 日
I am not absolutely certain what you want.
If you want one plot for the first and last subplots, rather than multiple lines in each one, sort them by first sorting ‘randgeneration’ and using that index for it and the others (the second and third subplots are histograms, so the order is irrelevant for them) —
mu = 1;
sigma = 5; % make the distribution as wide as we want.
N = 100;
randgeneration = randn(N,1)*sigma + mu;
[~,ix] = sort(randgeneration); % Create Sorting Index
pdfNormal = normpdf(randgeneration, mu, sigma);
figure;
subplot(2,2,1)
plot(randgeneration(ix), pdfNormal(ix));
xlabel('randomgeneration');
ylabel('pdfNormal');
subplot(2,2,2)
histogram(randgeneration);
subplot(2,2,3)
histfit(randgeneration);
subplot(2,2,4);
pd=makedist('Normal'); %create probability distribution object
cumulativedis=cdf(pd,randgeneration);
plot(randgeneration(ix),cumulativedis(ix),'r-.');
xlabel('randgeneration');
ylabel('CDF');
disp(mean(randgeneration));
disp(std(randgeneration))
.
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Subplots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!