Stuart’s MATLAB Videos

Watch and Learn

Deleting an element from a cell array

I recently had a situation where I needed to delete an entry from a cell array. When I tried A{3} = [ ], I did not delete the third element, I actual just set it to [ ].

What Loren helped me realize is that cell arrays use () just like regular MATLAB arrays to index into elements of the array, while preserving type of the container. i.e., index into a numeric array with () and you’ll get a numeric array back. Index into a cell array with () and you’ll get a cell array back. {} represents an additional syntax to access the underlying data.

  • print


댓글을 남기려면 링크 를 클릭하여 MathWorks 계정에 로그인하거나 계정을 새로 만드십시오.