How to plot a histogram showing percentage change?

6 vues (au cours des 30 derniers jours)
inspiration
inspiration le 2 Mai 2019
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.
  1 commentaire
KSSV
KSSV le 2 Mai 2019
Read about hist , histogram.

Connectez-vous pour commenter.

Réponses (1)

Kanishk
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!

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by