setting bins for 3D histogram

조회 수: 5 (최근 30일)
Dave Aceti
Dave Aceti 2014년 3월 12일
답변: Dave Aceti 2014년 3월 14일
I can generate a 3D histogram using the command
>> hist3(affin_occur_z2(1:11046,1:2));figure(gcf);
but I want to change the default number of bins (10) to something like 100.
I think the number of bins should go where the question mark is, but I get a "number of bins must be specified with a 2-element numeric vector" if I put a number there. >> hist3(affin_occur_z2(1:11046,1:2)?);figure(gcf);
What is the correct format?
Thank you very much.

채택된 답변

Dave Aceti
Dave Aceti 2014년 3월 14일
Before looking at the hist3 documentation, found out from a colleague that the syntax is;
hist3(affin_occur_z2(1:11046,1:2),[100 100]);figure(gcf);
where [100 100] is the "2-element numeric vector" that specifies 100 bins for each data set.

추가 답변 (1개)

Dave Aceti
Dave Aceti 2014년 3월 12일
Thanks but I still don't understand the syntax; from above it sounds like I should use;
>> 'hist3(affin_occur_z2(1:11046,1:2),100);figure(gcf);
which gives Error: A MATLAB string constant is not terminated properly.
or maybe
>> hist3(affin_occur_z2(1:11046,1:2),100);figure(gcf);
which gives Error using hist3 (line 111) The number of bins must be specified with a 2-element numeric vector.
  댓글 수: 1
Star Strider
Star Strider 2014년 3월 12일
Eliminating the (') in this line should eliminate the string termination error:
'hist3(affin_occur_z2(1:11046,1:2),100);figure(gcf);
try:
hist3(affin_occur_z2(1:11046,1:2),100);figure(gcf);
For ‘Error using hist3 (line 111) The number of bins must be specified with a 2-element numeric vector.’, please see the hist3 documentation. It explains it much better than I ever could. Click on the entries under the Examples section near the end of the page.

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

카테고리

Help CenterFile Exchange에서 Histograms에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by