generate 11x11x11 symmetric matrix from 6x6x6 matrix

2 ビュー (過去 30 日間)
Jim O'Doherty
Jim O'Doherty 2012 年 11 月 7 日
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 Center および File ExchangeMatrices and Arrays についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by