How to plot a histogram showing percentage change?

6 views (last 30 days)
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.

Answers (1)

Kanishk
Kanishk on 3 Jul 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!