How to plot a histogram showing percentage change?
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have 20 subjects divided equally into 2 classes A and B. Each class has a 10x1 vector, that has the percentage change of brain tissue for 10 subjects. I need to plot a historam depicting this percentage change in brain tissue for both the classes. Any help is appreciated.
Réponses (1)
Kanishk
le 3 Juil 2025
Hello Insipiration,
You can plot Histograms in MATLAB using "histogram" function. You can learn more about the "histogram" function from this MATLAB documentation.
You can use the following code to plot overlapping histograms:
A = randn(10,1) * 5 + 10;
B = randn(10,1) * 5 + 12;
figure;
histogram(A, 'BinWidth', 2, 'FaceAlpha', 0.6, 'FaceColor', 'b');
hold on;
histogram(B, 'BinWidth', 2, 'FaceAlpha', 0.6, 'FaceColor', 'r');
hold off;
legend('Class A', 'Class B');
xlabel('Percentage Change in Brain Tissue');
ylabel('Number of Subjects');
title('Histogram of Brain Tissue Change by Class');
grid on;
Cheers!
0 commentaires
Voir également
Catégories
En savoir plus sur Histograms 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!