Deleting a Cell and shifting cells left

63 Ansichten (letzte 30 Tage)
Ibro Tutic
Ibro Tutic am 1 Aug. 2017
Kommentiert: Aurelien Gregor am 24 Jan. 2023
I need to remove the n-th data (in a 1xn vector) and shift over the rest of the contents to the left by one. How would I do this?
Assume we had a cell array
a = {'1' '2' '3' '4' '5' '6' '7' '8' '9'}.
We want to delete the third entry and move over all of the data.
a{3}={}
So then
a={'1' '2' '' '4' '5' '6' '7' '8' '9'}.
Move data 1 column to the left to get rid of empty space
a={'1' '2' '4' '5' '6' '7' '8' '9'}.

Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 1 Aug. 2017
a = {'1' '2' '3' '4' '5' '6' '7' '8' '9'}
a(3)=[]
  3 Kommentare
Paul Wintz
Paul Wintz am 16 Aug. 2021
It's worth noting that a(3)=[] deletes the entry, but a{3}=[] sets the entry to contain an empty array.
Aurelien Gregor
Aurelien Gregor am 24 Jan. 2023
Thanks for this note.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Data Types finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by