How can I plot Histograms for multiple data

I have about 20 .mat data and I need a code to load all the data from a folder and calculate their histograms. cheers.

댓글 수: 1

Geoff Hayes
Geoff Hayes 2014년 12월 1일
Kemi - what have you tried so far? See load to load a mat data file, and hist to create the histogram.

댓글을 달려면 로그인하십시오.

 채택된 답변

Image Analyst
Image Analyst 2014년 12월 1일

0 개 추천

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

Thanks very much for this solution. Could you please check for me if this code will work. I just put them together based on the FAQ I read.
k = 1:20
matFileName = sprintf('mat%d.mat', k);
matData = load(matFileName);
[counts,binCentres] = hist(matData, 100);
hold on;
plot(binCenters, counts, ' color', rand(1,3));
end
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);

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Histograms에 대해 자세히 알아보기

태그

질문:

2014년 12월 1일

댓글:

2014년 12월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by