Adding elements in column vectors

86 Ansichten (letzte 30 Tage)
David Jones
David Jones am 10 Jun. 2021
Kommentiert: Scott MacKenzie am 10 Jun. 2021
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 Kommentar
Scott MacKenzie
Scott MacKenzie am 10 Jun. 2021
Bearbeitet: Scott MacKenzie am 10 Jun. 2021
You want to concatenate the vectors a and b. This is one of the most basic operations in MATLAB. All the details are here.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Max Heiken
Max Heiken am 10 Jun. 2021
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 Kommentar
Scott MacKenzie
Scott MacKenzie am 10 Jun. 2021
Yes indeed, but horizontal concatenation won't work in this case because a is 1x500 and b is1x6000 and both are column vectors.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

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

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by