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!