Filter löschen
Filter löschen

How to append a new element to a cell object A?

1.145 Ansichten (letzte 30 Tage)
fan feng
fan feng am 8 Jun. 2015
Beantwortet: geofo am 3 Dez. 2021
>>A={'a';'b'};
I want to append a new element,say 'c', to A, how could I do?
I would appreciate if you could help me.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 8 Jun. 2015
A{end+1} = c;
  6 Kommentare
Christopher Davis
Christopher Davis am 10 Jan. 2021
That's really helpful, not sure if it's proper terminology but I've heard this refered to as prepend
Pedro Miranda Pinheiro
Pedro Miranda Pinheiro am 14 Sep. 2021
Thank you, @Walter Roberson! @Christopher Davis, prepend is used for insertion of an element in the begining of a data structure. Append is the one used for end insertion as mentioned above.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

geofo
geofo am 3 Dez. 2021
>> A=[A;'c'];

Kategorien

Mehr zu Structures finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by