Simple array addition question

3 ビュー (過去 30 日間)
Robert
Robert 2012 年 11 月 20 日
回答済み: Jitesh Kumar 2018 年 9 月 26 日
if I have a matrix [1,2] and I want to add a 3rd element [3] to make [1,2,3]
And what is this simple manipulation called? 2 hours of searching has got me nowhere.
Kind regards
RK
  2 件のコメント
Jan
Jan 2012 年 11 月 20 日
編集済み: Jan 2012 年 11 月 20 日
@Robert: The operation is called "concatenation". Such questions are exhaustively explained in the "Getting Started" chapter of the documentation. While it is strongly recommended to read them, because Matlab is a very powerful language, the forum is not the right place to learn the very basics. Thanks.
Robert
Robert 2012 年 11 月 25 日
Sorry for not being able to find it and being thick, Yes this is how your question addresses me. Dyslexia can be very cruel, yet it spawns all of the greatest thinkers of our time. How is this very useful bit of advice going to help someone trying to learn. I suppose you have never had difficulty finding a simple answer before. If you don't like the question just don't answer it! We should be encouraging people not making them too scared to ask for help. Not impressed one iota!

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

採用された回答

per isakson
per isakson 2012 年 11 月 20 日
Hint:
x = [ 1, 2 ];
x(end+1) = 3;
or
x = cat( 2, x, 3 );
  1 件のコメント
Jan
Jan 2012 年 11 月 20 日
編集済み: Jan 2012 年 11 月 20 日
And:
x = [x, 3]
which is equivalent to:
x = horzcat(x, 3)

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

その他の回答 (1 件)

Jitesh Kumar
Jitesh Kumar 2018 年 9 月 26 日
A=[1,2]; A(end+1)=3;

カテゴリ

Help Center および File ExchangeRandom Number Generation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by