# Issue with cell during for loop operation

2 Ansichten (letzte 30 Tage)
Turbulence Analysis am 4 Feb. 2022
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 KommentareKeine anzeigenKeine ausblenden
Ankit am 4 Feb. 2022
but you have more than ~1000x3 entries for the column 193 - 200? what you want to do for these cells?
Turbulence Analysis am 4 Feb. 2022
Hi,
Sorry, that was a mistake in the previously attached file. Here, I have uploaded the new file.
For instance, if we consider the first entry i.e. Data1 {1,1} (in the attached file) where the array size is 38 x 3. Here, for instance, in the third column, the entries starting from 7, 8, 10 ..., here my goal is insert zero for the missing no's i.e. for 1 to 6.. likewise for all the missing no's in the third column... In this way, the third column will have no's to 1 to 100 and size of all the entries will be uniform i.e. 100 x 3..
Hope this helps!!

Melden Sie sich an, um zu kommentieren.

### Antworten (1)

Benjamin Thompson am 4 Feb. 2022
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 KommentareKeine anzeigenKeine ausblenden
Benjamin Thompson am 4 Feb. 2022
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
Turbulence Analysis am 4 Feb. 2022
Thanks.
However, the idea is to insert zero entry into the second column with respect to the missing number in the third colum.. As shown in the attached figure..
In this the third column always have numbers starting from 1 to 100 without any discontinuties, so the size will be 100 x 3

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by