如何水平连接矩阵? [英] How to concatenate matrices horizontally?
本文介绍了如何水平连接矩阵?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个 3 -by- 3 矩阵:
I have two 3-by-3 matrices:
A= [ 1 2 3
1 1 1
0 1 1]
B= [ 1 2 1
1 1 1
2 2 2]
如何连接A
和B
矩阵以创建如下所示的concat
矩阵?
How do I concatenate the A
and B
matrices to create the concat
matrix as seen below?
concat= [1 2 3 1 2 1
1 1 1 1 1 1
0 1 1 2 2 2]
推荐答案
这里有几种可能.最简单,最常见的一种:
There are a few possibilities here. The easiest, and most common one:
concat = [A, B]
以下内容被某些人认为是更可靠的(因为偶然地,可能会执行concat = [A; B]
,这会垂直将它们连接起来):
The following is considered more robust by some, (because one might, on accident, do concat = [A; B]
, which would concatenate them vertically):
concat = horzcat(A, B)
这篇关于如何水平连接矩阵?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文