As long as your data meet some assumptions:
- each group contains exactly the same number of rows (four in your example), and
- each row contains one non-empty data value (in columns 2 - 5).
- The groups are contiguous.
>> C = {...
'Rating1' [] [] [] '8'
'Rating1' [] [] '3' []
'Rating1' '2' [] [] []
'Rating1' [] '4' [] []
'Rating2' '5' [] [] []
'Rating2' [] '6' [] []
'Rating2' [] [] '3' []
'Rating2' [] [] [] '7'
'Rating3' '7' [] [] []
'Rating3' [] '7' [] []
'Rating3' [] [] '3' []
'Rating3' [] [] [] '7'
};
>> D = permute(reshape(C(:,2:5),4,[],4),[1,3,2]);
>> D(cellfun('isempty',D)) = [];
>> D = [C(1:4:end,1),reshape(D,4,[]).']
D =
'Rating1' '2' '4' '3' '8'
'Rating2' '5' '6' '3' '7'
'Rating3' '7' '7' '3' '7'
Best Answer