How to draw an histogram?
Show older comments
How do I draw an histogram knowing the number of times all elements in a 150x150 matrix appears using matlab?
Accepted Answer
More Answers (1)
f you already have the matrix, use it directly. If not, here is an example of how you can generate a random matrix with integers for demonstration purposes:
% Generate a 150x150 matrix with random integers from 1 to 100
matrix = randi(100, 150, 150);
% Flatten the matrix to a vector
flattenedMatrix = matrix(:);
% Plot histogram using the appropriate method
histogram(flattenedMatrix, 'BinMethod', 'integers');
xlabel('Element value');
ylabel('Frequency');
title('Element frequency in 150x150 matrix');
Categories
Find more on Histograms in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


