Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
例如,我有一个 6x6 矩阵,然后我想取出位于该矩阵中心的小矩阵,比如 2x2。有什么聪明的方法吗?或者我必须遍历旧矩阵,然后将值复制到新矩阵? 非常感谢你。
当然可以。例如尝试
A = rand(6,6); % // big matrix, an example B = A(3:4,3:4); % // central sub matrix obtained using indices
这(在这种情况下)也相当于
B = A([3 4],[3 4]);
通常,您可以从选择您感兴趣的索引的向量中提取子向量。