MATLAB Answers

How to insert a column in a cell array

266 views (last 30 days)
Rene M
Rene M on 26 Feb 2020
Commented: Rene M on 27 Feb 2020
Hello everyone,
I am trying to insert a new empty column inside a cell array between two existing columns without deleting one of them. I basically want to perform the task ('Insert column to the left') shown in the picture below by code:
I hope someone can help me with this.
Thanks in advance.

Accepted Answer

David Hill
David Hill on 26 Feb 2020
Cell arrays can contain anything in there cells. Inserting a empty holder for a column vector:
b={a{1:2},[],a{3:end}}
  1 Comment
Rene M
Rene M on 27 Feb 2020
Nice, it works. thank you very much!

Sign in to comment.

More Answers (0)

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!