필터 지우기
필터 지우기

generate 11x11x11 symmetric matrix from 6x6x6 matrix

조회 수: 1 (최근 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 CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by