How to vectorize the multiplication of arrays with DIM=5?

조회 수: 1 (최근 30일)
AP
AP 2014년 5월 29일
편집: AP 2014년 5월 29일
I have a three dimensional domain in MATLAB. For each point in the domain I have defined three arrays of size (NX,NY,NZ) at each point of the domain:
A1; % size(A1) = [NX NY NZ]
A2; % size(A2) = [NX NY NZ]
A3; % size(A3) = [NX NY NZ]
For each element, I am trying to construct an array which holds the value of A1, A2, and A3. Would the following be a good candidate for having a 1×3 vector at each point?
B = [A1(:) A2(:) A3(:)];
B = reshape(B, [size(A1) 1 3]);
If the 1×3 array is named C, I am trying to find C'*C at each point.
C = [A1(i,j,k) A2(i,j,k) A3(i,j,k)]; % size(C) = [1 3]
D = C'*C; % size(D) = [3 3]
My ultimate goal is to find the array D with size 3×3 for all the points in the domain in a vectorize fashion? Could someone help me?
  댓글 수: 2
Matt J
Matt J 2014년 5월 29일
Are you sure you don't mean the inner product
C(i,j,k) = [A1(i,j,k) A2(i,j,k) A3(i,j,k)]*[A1(i,j,k) A2(i,j,k) A3(i,j,k)]'
The expression you have is a non-scalar, outer product and cannot be assigned to a scalar location C(i,j,k).
AP
AP 2014년 5월 29일
편집: AP 2014년 5월 29일
Sorry for the confusion. I am not looking for inner product. I have updated my question and explained it in a better way.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by