Calculation with three dimensional matrices

조회 수: 5 (최근 30일)
Hancheng Zhu
Hancheng Zhu 2025년 1월 18일
댓글: Hancheng Zhu 2025년 1월 22일
I want to calculate a vector , with each element defined as follows
, where is the set of N dimensional vector, and is also the set of N dimensional vector, c is a constant. The superscript T is denoted as the transpose operation.
In my matlab code, is stored as a three dimensional matrix G, its dimension is (where ).
is also stored as a three dimensional matrix W, its dimension is (where ). c is a scalar.
I know i can use multiple for loop to calculate this vector Y, but it is too inefficient. Is there any some fast way to calculate it, maybe use three-dimensional matrix calculation method?
  댓글 수: 9
Torsten
Torsten 2025년 1월 21일
I've made the opposite experience.
Imagine you have code for the computation of Y_i. I would be really surprised if it were easier to read than the mathematical formula from above.
Paul
Paul 2025년 1월 21일
Perhaps you should post the code that you have along with sample input data.

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

채택된 답변

埃博拉酱
埃博拉酱 2025년 1월 22일
If your formula expresses what @Torsten understands, I'll code like this:
function Y=cGW_Y(c,G,W)
Y=permute(pagemtimes(permute(G,[2,3,1]),permute(W,[3,2,1])),[4,3,2,1]);%1×K×I×J
Y=pagemtimes(Y,'none',Y,'ctranspose');%1×1×I×J
Y=log2(sum(Y./(sum(Y,3)+c*c-Y),4)+1);%1×1×I
end

추가 답변 (1개)

Divyanshu
Divyanshu 2025년 1월 21일
You can try using 'pagetimes' function of MATLAB. For more details about 'pagetimes' refer the following documentation link:
Additionally, you can take reference from following MATLAB answer thread as well:
Hope it helps!

카테고리

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

제품


릴리스

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by