Merging and overwiting vectors

2 ビュー (過去 30 日間)
Giorgis
Giorgis 2017 年 3 月 24 日
コメント済み: Giorgis 2017 年 3 月 24 日
Hi
Say I have a vector A = [1;2;3;4;5;6] and B = zeros(20,1). How can I merge those two, in such a way that the size of the resulting vector to have size 20 x 1 and the content of the vector to be [1 2 3 4 5 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0].
When trying Y=[A;B] the results is a 26 element vector.
Thanks for any advice.

採用された回答

Andrei Bobrov
Andrei Bobrov 2017 年 3 月 24 日
Y = B;
Y(1:numel(A)) = A;
  1 件のコメント
Giorgis
Giorgis 2017 年 3 月 24 日
Thanks, you are a superstar!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStructures についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by