Error when using histogram2: array is wrong shape or size

2 visualizzazioni (ultimi 30 giorni)
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 Commenti
Gustavo Araújo Rodríguez
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.

Accedi per commentare.

Risposte (0)

Prodotti


Release

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by