Deleting a Cell and shifting cells left

58 ビュー (過去 30 日間)
Ibro Tutic
Ibro Tutic 2017 年 8 月 1 日
コメント済み: Aurelien Gregor 2023 年 1 月 24 日
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'}.

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2017 年 8 月 1 日
a = {'1' '2' '3' '4' '5' '6' '7' '8' '9'}
a(3)=[]
  3 件のコメント
Paul Wintz
Paul Wintz 2021 年 8 月 16 日
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 2023 年 1 月 24 日
Thanks for this note.

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by