Do not assign the results of sort() directly into omega_qus(:,r) . Instead, assign it to a temporary variable. Compare the size of the temporary variable to the existing number of rows of omega_qus. If the size of the temporary variable is no larger than the existing omega_qus rows, then assign
LT = length(Temp);
omega_qus(1:LT, r) = Temp;
omega_qus(LT+1:end, r) = FILLER;
where FILLER is a value you have chosen to signal that the slot is not used. For example you might use NaN.
If the size of the temporary variable is longer than the eixsting omega_qus rows, then assign
LT = length(Temp);
omega_qus(end+1:LT, 1:r-1) = FILLER;
omega_qus(:,r) = Temp;
where FILLER is the same as above, a value you have chosen to signal that a slot is not used.
In the special case that the FILLER value is 0, then the code can be abbreviated.
The alternative to using a FILLER is to make omega_qus a cell array.
Best Answer