Need help displaying the matrix in Conway's game of life
3 ビュー (過去 30 日間)
古いコメントを表示
So I cannot find a good way to display and then update the checkerboard during consecutive iterations of the game of life.
I am currently using mat2gray() to convert the matrix to grayscale, and then imshow() to display the matrix. But doing it this way slows down my laptop quite a lot, and I have to close and reopen the image with each iteration.
Is there a way to keep the existing matrix open (perhaps not as an image file) and update it live?
Many thanks,
Joe
0 件のコメント
回答 (1 件)
Stephen23
2018 年 2 月 5 日
"Is there a way to keep the existing matrix open (perhaps not as an image file) and update it live?"
Create the image as a matrix, and display it using image. Make sure that you obtain the image handle:
imh = image(M);
then simply update the image handle's data whenever you want:
set(imh,'CData',M)
Read more in the MATLAB documentation:
2 件のコメント
Guillaume
2018 年 2 月 5 日
Assuming the matrix is just 0s and 1s, I recommend using
imh = image(M, 'CdataMapping', 'scaled')
colormap gray
参考
カテゴリ
Help Center および File Exchange で Conway's Game of Life についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!