Hi.
I'm making the matrix with sortrows.
Here is what I want to make it.
20 20 2020 20 2120 20 2220 20 2320 20 2420 20 2520 21 2020 21 2120 21 2220 21 2320 21 2420 21 2520 22 20.....
To do this I tried with this code:
A=[20 21 22 23 24 25];B=[20 21 22 23 24 25];C=[20 21 22 23 24 25];sets = {A, B, C};[x y z] = ndgrid(sets{:});cartProd = [x(:) y(:) z(:)];sorted_cartProd = sortrows(cartProd, 1);sorted_cartProd
Then I got this.
sorted_cartProd = 20 20 20 20 21 20 20 22 20 20 23 20 20 24 20 20 25 20 20 20 21 20 21 21 20 22 21 20 23 21 20 24 21 20 25 21 20 20 22 20 21 22 ...
What I expect is start from third column but it starts to change from sedone column.
In this case, what should I do?
Best Answer