MATLAB Answers

How to use imagesc in a time loop?

조회 수: 4(최근 30일)
Tilia Selldén
Tilia Selldén 15 Nov 2019
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

  댓글 수: 0

로그인 to comment.

채택된 답변

KSSV
KSSV 15 Nov 2019
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 15 Nov 2019
I have tried that but that only generates the last figure and not the time siries

로그인 to comment.

More Answers (0)

이 질문에 답변하려면 로그인을(를) 수행하십시오.


Translated by