generate 11x11x11 symmetric matrix from 6x6x6 matrix

2 次查看(过去 30 天)
Hello,
I'm slowly going mad trying to accomplish something I feel is actually rather simple.
I've got a 6x6x6 matrix which I would like to be symmetric around all the principal axes about the point (1,1,1), thus making me an 11x11x11 matrix. Rather than having to do this the long way (and I have quite a few arrays to do this on), is there a quick command that would do this for me, perhaps some combination of fliplr/flipud?
Thanks,
Jim
  4 个评论
Jim O'Doherty
Jim O'Doherty 2012-11-7
编辑:Jim O'Doherty 2012-11-7
Apologies, yes I meant an array rather than matrix.
The "long way" would be me manually copying the array values into their correct positions.
Maybe its best shown with a 2-D example (I've shortened the array from 6x6 for space):
t=[788404.4 122836.9 2857.7
122836.9 32833.4 994.4
2857.7 994.4 31.9
7.3 5.4 3.9
3.2 3.0 2.6
2.1 2.0 1.8
];
should result in:
t_r = [2857.7 122836.9 788404.4 122836.9 2857.7
994.4 32833.4 122836.9 32833.4 994.4
31.9 994.4 2857.7 994.4 31.9
3.9 5.4 7.3 5.4 3.9
2.6 3.0 3.2 3.0 2.6
1.8 2.0 2.1 2.0 1.8
];
For a 2D matrix, this "flip" in matrix "t" would happen to the left and upwards, so that the value 788404.4 located at (1,1) would become the value at the centre of the new matrix
EDIT: the new matrix would now be of dimensions 11x5
Jan
Jan 2012-11-7
And Jose-Luis' question would result in:
a = [1 2;
3 4];
b = [4 3 4;
2 1 2;
4 3 4];
You example handles the columns only. But "[6x6x6]->[11x11x11]" implies, that the rows should be handled also. Am I right?

请先登录,再进行评论。

采纳的回答

Jan
Jan 2012-11-7
编辑:Jan 2012-11-7
n = 6;
A = rand(n, n, n);
v = [n:-1:2, 1:n];
B = A(v, :, :);
C = B(:, v, :);
D = C(:, :, v);
  2 个评论
Jim O'Doherty
Jim O'Doherty 2012-11-7
Thank you so much, this is exactly what I was looking to achieve!
Jim
Jan
Jan 2012-11-7
There must be a one-liner also. Unfortunately I cannot run Matlab currently to test this.

请先登录,再进行评论。

更多回答(0 个)

类别

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

标签

Community Treasure Hunt

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

Start Hunting!

Translated by