Next
t = magic(4);
k = 1:4;
tt(k,:) = sort(t(k,:)) %
t(k,:)is a 4x4 matrix. Therefore, it sortwill apply its standard 1-dimensional sort, i.e. Wrt lines. Note that you can specify sortto sort by the second dimension. those. wrt columns
tt(k,:) = sort(t(k,:),2)
In another case k- an integer, and t(k,:)- a vector of a line 1x4; therefore, sorting will be done by wrt columns.
t = magic(4);
for k = 1:4
tt(k,:) = sort(t(k,:))
end
, @Luis Mendo: , , :
: sort ( Matlab) , - . , .