1

我只有非常基本的 Maple 技能,不确定如何以图形方式将矩阵表示为块,其中矩阵中的 1 对应于块,0 对应于空白空间。

请参阅下面的代码,我在其中添加一个“1”,即循环中的中央列的块。我想知道这是否可以在枫木中进行动画处理,将“1”作为实心方块。

这是某人使用不同软件取得的成果的图片。任何帮助将不胜感激,谢谢。

restart;
with(LinearAlgebra):
with(MTM);
with(RandomTools);


M := Matrix([[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1]]);


for a to 4 do if (sum(M, 1))[3] < 5 
then z := max(ListTools[SearchAll](0, M..., 3))); 
M(z, 3) := M(z, 3)+1 
end if; 
print(M):
end do;
4

1 回答 1

1

我相信 Maple 命令plots:-sparsematrixplot可以帮助您完成大部分工作。可以使用 plots:-display 命令及其insequence选项为一系列此类绘图设置动画。例如,10 个随机矩阵:

L := NULL;
to 10 do
    L := L, plots:-sparsematrixplot(LinearAlgebra:-RandomMatrix(6, 6, generator = 0 .. 1));
end do;

plots:-display(L, insequence)
于 2017-04-25T22:03:21.843 回答