How to Multiply the following matrices case?

1 Ansicht (letzte 30 Tage)
M
M am 17 Mai 2022
Bearbeitet: Matt J am 17 Mai 2022
How to Multiply the following matrices case:
There is a matrix "T" with size 3*3*18 and another vector array "D" with size 3*1*18
I want to multiply the first matrix in T, I mean with size 3*3*1 with all other vectors in D but dont include the one that have the same slice i.e. multiply by the vector rom size 3*1*2 to 3*1*18 ... and store the output answers.
Do the same for the 2nd,3rd ..... matrices in T .... (Don't multiply the Matrix T with specific slice number with same slice number at D)
continue multiplying the 2nd T with all D but dont include the second D .... and so on for all T and D ..

Akzeptierte Antwort

Matt J
Matt J am 17 Mai 2022
Bearbeitet: Matt J am 17 Mai 2022
T=rand(3,3,18); D=rand(3,1,18);
M=pagemtimes(T,D(:,:));
M(:,logical(eye(18)))=[];
M=reshape(M,3,17,18);
whos M
Name Size Bytes Class Attributes M 3x17x18 7344 double
  10 Kommentare
Torsten
Torsten am 17 Mai 2022
Only as cell array of matrices M{i} because it is tedious to number the matrices M1,...,M18.
Does this fit your needs ?
Matt J
Matt J am 17 Mai 2022
Bearbeitet: Matt J am 17 Mai 2022
What is "separately"? Do you mean in separate elements of a cell array?
T=rand(3,3,18); D=rand(3,1,18);
M=pagemtimes(T,D(:,:));
M(:,logical(eye(18)))=[];
M=reshape(M,3,17,18);
M=reshape( num2cell(M,[1,2]) ,18,1)
M = 18×1 cell array
{3×17 double} {3×17 double} {3×17 double} {3×17 double} {3×17 double} {3×17 double} {3×17 double} {3×17 double} {3×17 double} {3×17 double} {3×17 double} {3×17 double} {3×17 double} {3×17 double} {3×17 double} {3×17 double}
whos M
Name Size Bytes Class Attributes M 18x1 9216 cell

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by