How to Multiply the following matrices case?
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
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 ..
採用された回答
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 件のコメント
@Matt J, This is not correct.
The output from multiplying the first T with all D expect the first D should be with size 3*1*17
and the same with other T and D .i.e repeat this 18 times
In my output, M(:,:,1) is the result of "multiplying the first T with all D expect the first D". A 3x17 matrix does hold 17 3x1 vectors.
Torsten
2022 年 5 月 17 日
You get 18 matrices of size 3x17. These are the matrices - in one big matrix.
@Matt J, you make the multiplication by one shot, I want it separately .
, I mean multiply T with size 3*3*1 with the vector D with size 3*1*2 then 3*1*3 ... until 3*1*18
M
2022 年 5 月 17 日
The output from the first multiplication should contain 17 vectors ... and same with other multiplication
It does already. Each M(:,:,i) contains seventeen 3x1 vector. If you don't like it in this form, you can use permute() to interchange the dimensions as you prefer it.
Torsten
2022 年 5 月 17 日
Only as cell array of matrices M{i} because it is tedious to number the matrices M1,...,M18.
Does this fit your needs ?
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
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Sparse Matrices についてさらに検索
参考
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
