Clearing part of an array
2 ビュー (過去 30 日間)
古いコメントを表示
I'm having a tough time figuring out the syntax to access specific columns in an array (and maybe even using the wrong terms to describe this...).
Say data=1x16 cell. If I want to clear the data but keep the columns intact, I have been doing data{1,8}={} and that clears column 1-8. However, I can not do data{9,16}={} to clear 9-16.
How would I do this? I'm sure it's something simple I am overlooking...
0 件のコメント
採用された回答
Kye Taylor
2013 年 1 月 29 日
Since data is a row of cells, the syntax
data{1,8} = {}
actually sets the 8th entry of data equal to the empty cell. To set each of the first eight entries of data equal to the empty cell, you can use
data(1:8) = {[]}
Similarly, clear the data in entries 9 through 16 using the syntax
data(9:16) = {[]}
0 件のコメント
その他の回答 (1 件)
Image Analyst
2013 年 1 月 29 日
編集済み: Image Analyst
2013 年 1 月 29 日
You must be doing 1:8, not 1 comma 8. {9,16} would refer to a single cell of a 2D cell array (the cell in the 9th row and 16th column of the 2D cell array), which you don't have - you have only a 1D cell array. To clear cells 9 through 16 use colon like 9:16.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Structures についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!