Error when using histogram2: array is wrong shape or size

조회 수: 2 (최근 30일)
Gustavo Araújo Rodríguez
Gustavo Araújo Rodríguez 2020년 4월 30일
댓글: Tommy 2020년 4월 30일
Hello,
I have the following 1-by-9 vectors representing the bin edges of a bivariate histogram:
DIST_BINS = [0 5 10 20 30 50 100 200 1000];
MAG_BINS = [5.00 5.50 6.00 6.50 7.00 7.50 8.00 8.50 9.00];
I also have a 8-by-8 matrix with the bin counts:
DEAG_MATRIX = [ 0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0;
0.0594 0.0485 0.0418 0.1706 0.0659 0.0039 0 0;
0 0 0 0 0 0 0 0;
0.0016 0.0029 0.0046 0.0250 0.0192 0.0067 0 0;
0 0 0.0000 0.0006 0.0006 0.0002 0 0;
0 0 0.0841 0.1712 0.1667 0.0109 0.0464 0.0683;
0 0 0 0.0001 0.0003 0.0000 0.0005 0.0000];
DEAG_MATRIX = round(DEAG_MATRIX*100)
When I try to use histogram2, I get the following error:
histogram2('XBinEdges',DIST_BINS,'YBinEdges',MAG_BINS,'BinCounts',DEAG_MATRIX)
Warning: Error creating or updating Quadrilateral
Error in value of property ColorData
Array is wrong shape or size
Warning: Error creating or updating Quadrilateral
Error in value of property ColorData
Array is wrong shape or size
Warning: Error creating or updating Quadrilateral
Error in value of property ColorData
Array is wrong shape or size
What am I doing wrong?
My version is MATLAB R2019b
  댓글 수: 3
Gustavo Araújo Rodríguez
Gustavo Araújo Rodríguez 2020년 4월 30일
It did not show any plot. However, I think I found the problem. I had created first an axes object and apparently MATLAB was trying to plot the histogram there. I added figure at the beginning and it worked.
Tommy
Tommy 2020년 4월 30일
Oh awesome!

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

답변 (0개)

카테고리

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

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by