MATLAB – updating the color of a surface plot with a callback

As long as the Cdata has the same height and width as the old map data (map100 dimensions = map200 dimensions) the colour data should be replaced without any issues. Here I created a random Cdata colour map but of course, this array can be set to any uint8 or double values you’d like. I’d suggest ensuring that Cdata is defined within your callback function before using it.

cyl = surf(X_Length,Y_Circle,Z_Circle,'Cdata',map100);
shading interp 

%Setting the surf to new test data%
[mapHeight,mapWidth] = size(map100);
map200 = rand(mapHeight,mapWidth);
cyl.CData = map200;

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top