How to use imagesc in a time loop?

조회 수: 3 (최근 30일)
Tilia Selldén
Tilia Selldén 2019년 11월 15일
댓글: Tilia Selldén 2019년 11월 15일
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