using histogram in a loop with hold on and off
6 次查看(过去 30 天)
显示 更早的评论
I am tyring to understand the use of the histogram in the following way.
I have a matrix of size (M x N). Each column represents a curve.
I calculate a mean for all the curves using mean_matrix = mean(matrix,2)
Plotting mean_matrix shows that the mean is as expected.
Next I subtract each curve from the mean value giving me a difference matrix Diff(M x N)
I then use histogram to plot Diff(M x N) so it is > hist(Diff, # of bins)
This give me a histogram with different colours, I think the different colours
are for each column of the Diff matrix ? I then took a look at using
a loop so I did >for i=1,index; hist(Diff(:,i),# of bins);end; and this
gave me a different looking graph; next I included hold on and again
I got a completely looking curve. Can someone help me understand what I did?
I would like to do is to look at the histogram curves in a 3D plot
and see the variation better.
0 个评论
回答(2 个)
Michael Haderlein
2014-7-24
I try to understand and to explain. Let's take a matrix, maybe the peaks-matrix (49x49 by default) and reshape it:
matrix=peaks; %49x49
matrix2=reshape(matrix,numel(matrix)/7,7); %343x7
hist(matrix2) %histogram with 7 bars each bin, one for each column of the matrix
figure, axes, hold all
for cnt=1:7
hist(matrix2(:,cnt))
end %7 histograms stacked upon each other -> difficult to see anything
h3=histc(matrix2,linspace(minv,maxv,21),1); %calculate a histogram for each column
bar3(h3) %plot the histogram for each column
Hope that helped,
best regards,
Michael
Michael Haderlein
2014-7-25
I see I forgot to post also the line where minv,maxv is created:
minv=min(matrix2(:));maxv=max(matrix2(:));
What happens, if you execute the above written just using your Diff matrix instead of my matrix2?
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Histograms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!