简体   繁体   English

我可以在 nD 矩阵上使用 mldivide“\”而不在 MATLAB 中使用 for 循环吗?

[英]Can I use mldivide “\” on an nD matrix without using for loops in MATLAB?

Could I use mldivide ( \ ) on an n-dimensional matrix in MATLAB without using for loops?我可以在 MATLAB 中的 n 维矩阵上使用mldivide ( \ ) 而不使用for循环吗? For example, if I have X=rand (5,5,2,3,6) and Y=[0;0;0;0;1];例如,如果我有X=rand (5,5,2,3,6)Y=[0;0;0;0;1]; , can I slice every 5*5 array along the other dimensions to solve it against Y ? ,我可以沿其他维度对每个 5*5 数组进行切片以针对Y解决它吗?

I solved it with the help of Bruno Luong and his multisolver found here .我在Bruno Luong和他的多重求解器的帮助下解决了这个问题 The code below can solve any number of dimensions, considering the first two dimensions are of the same size.考虑到前两个维度的大小相同,下面的代码可以解决任意数量的维度。

M=rand(5,5,2,3,6);
RHS=[0;0;0;0;1];
sx = size(M);
sy = size(RHS);
dx = ndims(M);
MSOL=MultiSolver(reshape(M,sx(1),sx(2),[]),RHS);
MSOL = reshape(MSOL, [sx(2) sy(2) sx(3:dx)]);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Matlab中的3D矩阵上可以使用mldivide“ \\” - Is it possible to use mldivide “\” on a 3D matrix in Matlab 在MATLAB中如何在没有for循环的情况下生成这个3-D矩阵? - How can I generate this 3-D matrix without for loops in MATLAB? MATLAB中无循环的矩阵计算 - Matrix calculations without loops in MATLAB 如何在不使用MATLAB中的循环的情况下从矩阵的每个m-m窗口中提取n个元素? - How can I extract n elements from each m-by-m window of a matrix without using loops in MATLAB? 我怎样才能获得与Matlab的'A \\ b`(mldivide)算子使用numpy / scipy返回的欠定线性系统相同的“特殊”解? - How can I obtain the same 'special' solutions to underdetermined linear systems that Matlab's `A \ b` (mldivide) operator returns using numpy/scipy? Octave / MATLAB:使用矩阵访问矩阵中的元素而无需循环 - Octave/MATLAB: Using a matrix to access elements in a matrix without loops 在Matlab中操作没有for循环的矩阵 - Manipulate matrix without for loops in Matlab Matlab矩阵运算无循环 - Matlab matrix operations without loops 在不使用'for'循环的情况下访问MATLAB中矩阵的所有元素 - Accessing all elements of a matrix in MATLAB without using 'for' loops 使用 matlab 循环的斐波那契矩阵 - Fibonacci matrix using loops of matlab
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM