
How to determine the probability using relative frequency histogram, kernel smoothing plot, empirical CDF plot, probability paper plots, and distribution fitting?
12 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
How do you create a graph showing different figures in matlab? This is what I have so far for the kernel distribution. My code is not working. What is wrong with it?
subplot(1,4,1);
ksdensity(C);
xlabel('X axis');
ylabel('Y axis');
title('kernel smoothing plot');
hold on;
[pdfks,xpdfks]=ksdensity(A);
plot(xpdfks,pdfks,'k');
x=linspace(-5,5,3000);
plot(x,normpdf(x),'r');
0 commentaires
Réponses (1)
Abhinav Aravindan
le 3 Jan 2025
I assume you are trying to create separate plots in a single figure window for "ksdensity", "pdfks" and "normpdf".
The “subplot” function can be used as specified in your code which divides the current figure into an m-by-n grid. The third input argument to "subplot" is used to specify the position of the plot in the figure. Using the “hold on” command retains plots in the current axes so that new plots are added to the same axes.
You may try modifying the code as follows by adding the required subplot position to achieve the desired output:
A = randn(1000, 1); % Example data for A
C = randn(1000, 1); % Example data for C
subplot(1,3,1);
ksdensity(C);
xlabel('X axis');
ylabel('Y axis');
title('kernel smoothing plot');
subplot(1,3,2);
[pdfks,xpdfks]=ksdensity(A);
plot(xpdfks,pdfks,'k');
subplot(1,3,3);
x=linspace(-5,5,3000);
plot(x,normpdf(x),'r');
Output:

Please refer to the below documentation on "subplot" for more detail:
0 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!