如何在Matlab中将矩阵的一部分分配给其他矩阵 [英] how to assign part of a matrix to other matrix in matlab

查看:3079
本文介绍了如何在Matlab中将矩阵的一部分分配给其他矩阵的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个30 x 30的矩阵,称为A,我想将B分配为A的最左边的30 x 20块?我该怎么做?

I have a 30 x 30 matrix, called A, and I want to assign B as the leftmost 30 x 20 block of A how can I do that?

这是正确的方法吗?

B = A[30 ; 20]

推荐答案

没有正确的方法

B = A(:, 1:20);

其中:是A中所有行的简写.

where : is shorthand for all of the rows in A.

MATLAB中的矩阵索引使用圆括号().方括号[]用于声明矩阵(或向量),如

Matrix indexing in MATLAB uses round brackets, (). Square brackets, [], are used to declare matrices (or vectors) as in

>> v = [1 2 3; 4 5 6; 7 8 9]
v =

     1     2     3
     4     5     6
     7     8     9

excaza 矩阵索引.

excaza provides a very good link on Matrix Indexing in MATLAB which should help you. There is also Matrix Indexing.

这篇关于如何在Matlab中将矩阵的一部分分配给其他矩阵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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