How can I plot Histograms for multiple data
1 view (last 30 days)
Show older comments
I have about 20 .mat data and I need a code to load all the data from a folder and calculate their histograms. cheers.
Accepted Answer
Image Analyst
on 1 Dec 2014
See the FAQ for code samples: http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F
Inside each loop call hist() and plot(). You might want to use a different color for each plot to distinguish them from each other.
[counts, binCenters] = hist(yourData, numberOfBins);
hold on;
plot(binCenters, counts, 'Color', rand(1,3));
2 Comments
Image Analyst
on 1 Dec 2014
You need the word "for" before the k= line. And you will need to extract your image from matData since matData is a structure:
fieldnames(matData) % Display contents of matdata in command window
myData = matData.whateverYouCalledYourData;
[counts,binCentres] = hist(myData, 100);
More Answers (0)
See Also
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!