我有一些统计值的对称矩阵,我想在 Matlab 中使用 imagesc 绘制这些值。矩阵的大小是 112 X 28,这意味着我想为每列显示 4 行。我怎样才能摆脱这个矩阵的上三角部分或下三角部分?因为这意味着每列删除 4 行对角线 tril 或 triu 函数不起作用(它们用于方阵)。
谢谢

最佳答案

有很好的答案,但也许这可以是使用 triu 函数的替代方法:

% image
img = rand(112, 28);

% utilize a square matrix to use triu command
temp = nan(112, 112);
temp(:, 1:4:end) = img;
temp = triu(temp, -3);

% put the relevant elements back
img = temp(:, 1:4:end);

关于matlab - 摆脱对称矩阵的上三角或下三角部分,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/42702441/

10-13 01:08