How to use imagesc in a time loop?

6 次查看(过去 30 天)
Hi,
I am using imagesc to visualize a binary matrix (of zeroes and ones), which, at every time step, changes (more ones apperars).
I want the figure to hold on each time step so that I can visulize the change in the matrix. How can i do that with out 100 figures popping up?
This is the code for the figure:
for time = 1:timeSteps
newMatrix = GenerateNewMatrix(matrix,probability);
matrix = newMatrix;
figure; hAxes = gca;
imagesc(hAxes, matrix);
colormap(hAxes , [1 1 1; 1 0 0; 0 1 0] );
end

采纳的回答

KSSV
KSSV 2019-11-15
for time = 1:timeSteps
newMatrix = GenerateNewMatrix(matrix,probability);
matrix = newMatrix;
hAxes = gca;
imagesc(hAxes, matrix);
colormap(hAxes , [1 1 1; 1 0 0; 0 1 0] );
end
Remove the figure line in the loop.
  1 个评论
Tilia Selldén
Tilia Selldén 2019-11-15
I have tried that but that only generates the last figure and not the time siries

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graphics Object Properties 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by