Matlab的:通过扩展其向量扩展矩阵 [英] Matlab: Extend a matrix by extending its vectors

查看:311
本文介绍了Matlab的:通过扩展其向量扩展矩阵的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 D X M X N 矩阵 A (间pretation:每个 N ,还有 M 尺寸 D )。我想延长每个d维向量如下:

I have a dxmxn matrix A (interpretation: for each n, there are m vectors of dimension d). I would like to extend each d-dimensional vector as follows:

考虑d维向量 v :(1,2,...,D)(这是(X_1,X_2,...,x_d),但我删除了X_为简单起见)。我们的目标是延长 v 来获得 D * D 格式的矢量:

Consider a vector v of dimension d: (1,2,...,d) (it's (x_1,x_2,...,x_d) but I removed the 'x_' for simplicity). The goal is to extend v to obtain a d*d vector of the form:

(1,1,...,1,2,...,2,...,D,D,...,D)

(1,1,...,1,2,...,2,...,d,d,...,d)

有谁请建议我一个快速的方法来做到这一点? (我想,使用循环和延伸各向量在每次迭代是很慢的。)

Could anybody please suggest me a fast way to do that? (I guess that using a loop and extending each vector at each iteration is very slow.)

感谢您提前对您有所帮助。

Thank you in advance for your help.

推荐答案

可恶!

reshape(permute(repmat(permute(A,[1 4 2 3]),[1 d]),[ 2 1 3 4]),d*d,m,n)

这篇关于Matlab的:通过扩展其向量扩展矩阵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆