heatmap function doesn't work (Error in heatmap (line 138))

I'm trying to use the heatmap function. I can't get it to work. I can't even get the example from the mathworks website to work:
cdata = [45 60 32; 43 54 76; 32 94 68; 23 95 58];
h = heatmap(cdata);
which returns:
Not enough input arguments.
(Error in heatmap (line 138)
[h3, Centers] = hist3([x1, x2], nbins) ;
I don't know how I can figure out what's wrong with my code, if the example doesn't even work. Any help would be appreciated.

5 Commenti

Let's check that you don't have more than 1 heatmap file. Could you return the results of this line below? It should produce one or more paths to heatmap files.
which heatmap -all
I think you're onto something. It returns 4 options (see below - I've removed some of the directory path that doesn't seem relevant). One looks like a file I downloaded from the file exchange, 2 in the MATLAB folder and 1 in the toolboxes folder, which is likely a third party tool box I downloaded (I've been trying all sorts of things to get a usable heatmap function).
I assume I should remove all but one? Of the two in the MATLAB directory, how do I know which one to remove?
D:\...\heatmap.m
C:\Program Files\MATLAB\R2019a\toolbox\matlab\bigdata\@tall\heatmap.m % tall method
C:\Program Files\MATLAB\R2019a\toolbox\matlab\specgraph\heatmap.m % Shadowed
C:\Users\...\Roaming\MathWorks\MATLAB Add-Ons\Toolboxes\Customizable Heat Maps\heatmap.m % Shadowed
I got rid of the the two that weren't in the MATLAB file (C:\Program Files\MATLAB\R2019a\toolbox\matlab\...) and it seems to be working now.
Is there supposed to be 2 heatmap functions (one is labelled as 'tall method', the other 'shadowed')? Should I be removing one, or leaving them?
Thanks for the help
Leave the ones that are subdirectories of: C:\Program Files\MATLAB\R2019a\toolbox\matlab\.
I would just slightly rename the one you downloaded from the File Exchange, so that it doesn’t overshadow the built-in MATLAB functions. Removimg it completely is unnecessary. It may have features you want.
Leave them both.
The one in the @tall directory is the heatmap method used when you try to create a heatmap plot with a tall array as input.
The one in the specgraph directory is the heatmap function used when you try to create a heatmap plot with normal double precision or table data.

Accedi per commentare.

 Risposta accettata

Adam Danz
Adam Danz il 7 Mag 2019
Modificato: Adam Danz il 7 Mag 2019
The problem was caused by a file named heatmap.m that overshadowed Matlab's built-in function of the same name. This was discovered after listing all files on path that had the name heatmap.
which heatmap -all
In r2019a (and presumably other recent releases) two files are listed that are associated with Matlab's heatmap() function.
C:\Program Files\MATLAB\R2019a\toolbox\matlab\specgraph\heatmap.m
C:\Program Files\MATLAB\R2019a\toolbox\matlab\bigdata\@tall\heatmap.m % tall method
The second one is used with tall arrays.

Più risposte (0)

Categorie

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by