Adding elements in column vectors

87 次查看(过去 30 天)
Hi
I have 2 colimn vectors a = 1:500 and b= 1:6000 I would like to make a new column vector c with (a first) and (b second) so the new column vector would bw c = 1:6500.
Any help would be greatly appreciated
Thank you
David
  1 个评论
Scott MacKenzie
Scott MacKenzie 2021-6-10
编辑:Scott MacKenzie 2021-6-10
You want to concatenate the vectors a and b. This is one of the most basic operations in MATLAB. All the details are here.

请先登录,再进行评论。

采纳的回答

Max Heiken
Max Heiken 2021-6-10
Hello,
you can concatenate vectors and matrices vertically with a semicolon like this
c = [a; b];
or concatenate them horizontally with a comma like this
c = [a, b];
  1 个评论
Scott MacKenzie
Scott MacKenzie 2021-6-10
Yes indeed, but horizontal concatenation won't work in this case because a is 1x500 and b is1x6000 and both are column vectors.

请先登录,再进行评论。

更多回答(1 个)

KSSV
KSSV 2021-6-10
MAke a and b of equal dimension using linspace. and then add.
Read about linspace.,

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

标签

产品


版本

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by