我的矩阵大(n * n),我想将其除以n * a个尺寸块,其中a由用户在matlab中给出
"Response": {
"inputs": {
"body": "@base64ToBinary(body('Decode_AS2_message')?['OutgoingMDN']?['Content'])",
"headers": "@body('Decode_AS2_message')?['OutgoingMDN']?['OutboundHeaders']",
"statusCode": 200
},
答案 0 :(得分:0)
MATLAB具有内置的reshape函数,可以完全满足您的需求:
n = size(matrix, 1);
res = reshape(matrix, n, a, []);
结果是n x a x n/a
矩阵res
。
更新:正如 @Adriaan 在评论中正确指出的那样,引入附加维度并不是将二维矩阵拆分为几个较小维度的唯一方法。使用Cell Arrays和mat2cell内置函数可以达到相同的结果:
res2 = mat2cell(matrix, [n], repmat(a, 1, n/a));