Squared heatmap with random transition; animation

6 ビュー (過去 30 日間)
Bidyut Bikash Goswami
Bidyut Bikash Goswami 2018 年 10 月 22 日
コメント済み: jonas 2018 年 10 月 23 日
Hi, I need to plot a40x40 squared heatmap animation, Something like the attached figure but a dynamic one where the color keep changing "randomly".
FYI, I have a system with 5 states 0, 1, 2, 3, and 4. Its a conditional system (Markov Chain) which can transit from one state to another. I need to present this concept in a visibly attractive way. That is why I want to plot this animation. Looking for suggestions and help. Thanks

採用された回答

jonas
jonas 2018 年 10 月 22 日
編集済み: jonas 2018 年 10 月 22 日
You could also use scatter with a superlarge markersize.
figure;
colormap([1 1 1;1 1 0;1 0 0;0 0 1;0 1 0]);
[X,Y] = meshgrid(1:40,1:40);
h = scatter(X(:),Y(:),50,randi([1 4],numel(X),1),'s','filled','markeredgecolor',[.5 .5 .5])
ax = gca;
set(ax,'visible','off')
ax.Position = ax.Position ./ [1 0.6 1.2 1.2];
axis equal
for j = 1:100;
h.CData = randi([1 5],numel(X),1);
pause(0.1)
end
  12 件のコメント
Bidyut Bikash Goswami
Bidyut Bikash Goswami 2018 年 10 月 23 日
Thanks a lot. Happily Accepted :)
jonas
jonas 2018 年 10 月 23 日
Thanks! Always happy to help!

サインインしてコメントする。

その他の回答 (1 件)

Jan
Jan 2018 年 10 月 22 日
What about pcolor?

カテゴリ

Help Center および File ExchangeData Distribution Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by