Sorry if bit of a silly question but how would i combine 2 vectors as below? Thanks in advance
a1 [ 1,2,3,4,5,6] a2 [ 7,8,9,10,11]
a3 = [1,2,3,4,5,6,7,8,9,10,11]

 採用された回答

John D'Errico
John D'Errico 2018 年 3 月 31 日

1 投票

You created a1 as
a1 = [1,2,3,4,5,6];
and a2 as
a2 = [7,8,9,10,11];
So why would you not be able to create a3 as
a3 = [a1,a2];
TRY IT!

4 件のコメント

Tom Heart
Tom Heart 2018 年 3 月 31 日
Thanks! My mistake why it didn't work when i tried it before!!
Chumani
Chumani 2022 年 9 月 12 日
  1. Input into MATLAB workspace the following vectors: A = (2 4 6 8), B = (5 10 15 20), and build up the vector C = (2 5 4 10 6 15 8 20).
Chumani
Chumani 2022 年 9 月 14 日
  1. Define a vector Y = (4, 7, -5, 10, 11, 0, -3, 12, 8, 19) and compute:
  • length(Y),
  • size(Y),
  • Y(10)=-Y(4),
  • Y(11)=Y(7)-Y(3).
Make the third and fifth elements equal to nine
Chaman Sabharawal
Chaman Sabharawal 2024 年 11 月 11 日
編集済み: Chaman Sabharawal 2024 年 11 月 11 日
x=1:2:16, y=12:2:16,
z(1:2:16) =x;
z(2:2:16)=y
merges x and y interveavingly

サインインしてコメントする。

その他の回答 (1 件)

Suryansh Shukla
Suryansh Shukla 2021 年 12 月 2 日

3 投票

As the question was already answered but if you have a column vector like a1 = [1,2,3,4,5,6]';
a2 = [7,8,9,10,11,12]';
then you can use
a3 = [a1;a2]

カテゴリ

タグ

質問済み:

2018 年 3 月 31 日

編集済み:

2024 年 11 月 11 日

Community Treasure Hunt

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

Start Hunting!

Translated by