MATLAB: Of Cell Arrays & Sort

cell arrays

Greetings,
for i=1:5
x{i}=i
end
for j=1:7
y{j}=j
end
merge_twocell = [x y]
Now say I have a variable, select_var and I want to select the lowest 3 values from x and 4 lowest values from y, how can I achieve this?
P/S I'm avoiding using cell2mat, sort the elements, then retrieve what I want. Is there a more direct approach?

Best Answer

x1=sortrows(x);y1=sortrows(y);
x_min=x1(1:3)
y_min=y1(1:4)
Related Question