Matlab的:CONCAT行向量到一个数组 [英] Matlab: concat row vectors into an array

查看:2289
本文介绍了Matlab的:CONCAT行向量到一个数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么可以添加,例如向量

how can I add, for example vector

v1 = [0 0 0 1]
v2 = [0 1 0 0]

让我得到一个数组

so that I get an array

a = 0 0 0 1
    0 1 0 0

和还添加更多的向量,到数组 A

and also add more vectors to, into array a?

推荐答案

一个部分从现有的答案,我建议你检查以下功能:horzcat,vertcat和重塑。

A part from the prior answers I suggest that you check the following functions: horzcat, vertcat and reshape.

比如测试这个code:

For instance test this code:

A1 = [1 2 3; 4 5 6; 7 8 9];
A2 = A1 + 10*ones(3,3); 
B1 = horzcat(A1,A2)         % horizontal concatenation
B1 = vertcat(A1,A2)         % vertical concatenation
v1 = reshape(A, 1, prod(size(A)))   % easily change the size of matrix

这篇关于Matlab的:CONCAT行向量到一个数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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