Issue with cell during for loop operation
1 回表示 (過去 30 日間)
古いコメントを表示
Hi,
I am genrating cells of size 1 x 200 through for loop operation. Ideally, for each iteation I should get a array of size 100 x 3 double in each cell. However, as shown in the attached .mat file, the first array is 38 x 3. Over here, my intenstion is to insert zero into the missed entries, in such a way to make all the arrays of size 100 x 3.. Could someone help me with this ??
2 件のコメント
Ankit
2022 年 2 月 4 日
but you have more than ~1000x3 entries for the column 193 - 200? what you want to do for these cells?
回答 (1 件)
Benjamin Thompson
2022 年 2 月 4 日
You can always copy a cell into a temp array, add zeros to increase array size, then write it back to the cell array:
temp = Data{1};
Data{1} = zeros(100,3);
size(temp)
temp((size(temp,1)+1):100,:) = 0;
Data{1} = temp;
size(Data{1})
2 件のコメント
Benjamin Thompson
2022 年 2 月 4 日
This is even easier and more efficient:
>> size(Data{7})
ans =
50 3
>> Data{7}((size(Data{7},1)+1):100,:) = 0;
>> size(Data{7})
ans =
100 3
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!