Filter löschen
Filter löschen

Transpose Translation Vector for addresses

2 Ansichten (letzte 30 Tage)
Aswas
Aswas am 20 Mai 2016
Kommentiert: Aswas am 20 Mai 2016
Hi, I have G =
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 0 0 0 0 0 0 0 0 0 0 0 0
-1 0 0 0 0 0 0 0 5 5 5 0 0
-1 0 0 0 0 0 0 0 0 0 5 0 0
-1 0 0 0 0 0 0 0 0 0 5 0 0
and have translation vector for X....
X = zeros(nx,2);
[r, c] = find(G == 0); % Fill (X) with free nodes from (G)
X = [r, c]
X =
2 2
3 2
4 2
5 2
2 3
3 3
4 3
5 3
2 4
3 4
4 4
5 4
. .
. .
. .
which is reading columnswise.
I would like to sort in this order
X =
2 2
2 3
2 4
. .
3 2
3 3
3 4
. .
4 2
4 3
4 4
. .
5 2
5 3
5 4
I have tried
X(r,c) = reshape([X' 5], [], rows - 1)'
but get:
Error using horzcat Dimensions of matrices being concatenated are not consistent.

Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 20 Mai 2016
Y=sortrows(X)

Weitere Antworten (0)

Kategorien

Mehr zu Multidimensional Arrays finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by