I have a surf figure plotting a two dimensional function. I have a loop which changes the z values at each point [x,y] in a meshgrid matrix, in order to animate my plot:
p = surf(x, y, z)
frames = 10/1000
for t = 0:frames:10
newZ = updateZVal(someArgs)
set(p, 'ZData', newZ)
This works fine for the most part. However, the color map does not update. Basically the colormap texture of the original z matrix just stays there. The x-y plane moves up and down with changes in newZ, but the color does not.
This exact code works in Matlab, and it works fine in Octave except for this color issue.
Edit: Minimal working example. Little moving gaussian type thing. You can see the color does not update
figure();
x_range = [-2:0.2:2];
y_range = [-2:0.2:2];
[x,y] = meshgrid(x_range, y_range);
frames = 500;
z = (x) .* y;
p = surf(x, y, z);
for t = [0:2/frames:2]
z = exp(-((((x-t).^2)/2) + (((y-t).^2)/2)));
set(p, 'ZData', z);
drawnow;
end
for t = 0:1000:10? - NKNtranging from0to10with1000steps - pretzlstyle