Colordata Error in Heatmap
Mostrar comentarios más antiguos
I am using heatmap like this:
FigureGenerated = heatmap(x_axis_val,y_axis_val,capture_status,'Colormap',mymap);
saveas(FigureGenerated,Path_Capture_Status);
where x_axis_val (1st column) and y_axis_val (2nd column) are created as per user input. And capture_status contains all values of the 5th column of the same matrix.
The code works fine sometimes, but at other times I get the following error:
Error using heatmap (line 53)
Number of x values must equal the number of columns in
'ColorData'.
How can this be solved?
Please help. Thanks a lot.
Respuestas (1)
Ameer Hamza
el 14 de Oct. de 2020
It means that if the dimensions are
n = numel(x_axis_val)
m = numel(y_axis_val)
Then the dimensions of capture_status should be m*n.
5 comentarios
Komal Shah
el 15 de Oct. de 2020
Ameer Hamza
el 15 de Oct. de 2020
These lines seems to work fine if the values are pre-defined
xpos1 = 1;
xpos2 = 10;
ypos1 = 7;
ypos2 = 3;
x_spac = 1;
y_spac = 1;
x_axis_val = xpos1:x_spac:xpos2;
y_axis_val = ypos2:(-y_spac):ypos1;
capture_status = zeros(numel(y_axis_val),numel(x_axis_val));
heatmap(x_axis_val, y_axis_val, capture_status)
Komal Shah
el 15 de Oct. de 2020
Ameer Hamza
el 15 de Oct. de 2020
You can use the breakpoints: https://www.mathworks.com/help/matlab/matlab_prog/set-breakpoints.html to find the error.
Komal Shah
el 15 de Oct. de 2020
Categorías
Más información sobre Data Distribution Plots en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!