フィルターのクリア

Add n+1 element to a vector

1 回表示 (過去 30 日間)
steve Brian
steve Brian 2020 年 4 月 10 日
コメント済み: Peng Li 2020 年 4 月 10 日
I have a vector of the format:
x = [X1 X2 … Xn]
I want to add an element to the end, X(n+1). How do I do that?
ex: x = [ 1 4 2 8]
newX = [ 1 4 2 8 9]

採用された回答

Peng Li
Peng Li 2020 年 4 月 10 日
If your X is a row vector, using newX = [X, aNewElement];
If your X is a column vector, using newX = [X; aNewElement];
  2 件のコメント
steve Brian
steve Brian 2020 年 4 月 10 日
but, i want aNewElement to be, n+1
like [ 1 4 2 8 8+1]
Peng Li
Peng Li 2020 年 4 月 10 日
newX = [X, X(end)+1];

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by