Transpose Translation Vector for addresses

2 次查看(过去 30 天)
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.

采纳的回答

Azzi Abdelmalek
Azzi Abdelmalek 2016-5-20

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Multidimensional Arrays 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by