matlab - 如何找到四个矩阵的行列式
问题描述
A=[1 2;3 4];
B=[5 6;7 8];
C=[8 7;6 5];
D=[4 3;2 1];
E=[det(A(1) B(1);C(1) D(1)) det(A(2) B(2);C(2) D(2));det(A(3) B(3);C(3) D(3)) det(A(4) B(4);C(4) D(4))]
我想得到一个等于的矩阵E
。
如果A B C D
非常大,这手写起来很麻烦。我怎样才能自动做到这一点?
解决方案
如果A
, B
, C
, 和D
, 变大, 但没有更多的矩阵被添加到这个列表中, 下面应该做:
A = rand(20);
B = rand(20);
C = rand(20);
D = rand(20);
E = zeros(size(A)); % initialise E as big as the others
for ii = 1:numel(A) % loop over linear indices
E(ii) = det([A(ii) B(ii);C(ii) D(ii)]); % build determinant
end
推荐阅读
- c# - CSVHELPER 在值为 null 或为空时有条件地忽略写入字段
- html - 我可以让浏览器选择 UTF-8 来查看源代码吗?
- windows - Cloudformation CFN-Init Windows Powershell 问题
- python - 阻止 Python 窗口关闭的问题
- floating-point - 将重复的二进制数转换为十进制
- asp.net-core - 如何设置“web.config”文件以显示完整的错误消息(.NET Core 2.1)
- linux - 引导 linux 内核和独立应用程序有什么区别?
- php - PHPMailer 仅将空值插入我的数据库中
- apache-kafka - 在 kafka 流处理期间执行高效的外部系统查询
- c# - 如何反序列化给定动态列列表的 api 响应?C# .NET 核心 2.2