Multidimensional array multiplication issue
古いコメントを表示
I have to matrices. Impulse = 32 by 32 , residual = 5021 by 32. I want each element in the columns in impulse to be multiplied with all elements of residual. This will be repeated for second column and added to the first. I want this for all the columns, with a loop. Please suggest...
2 件のコメント
KL
2017 年 10 月 22 日
what do you mean by "each element in the columns in impulse to be multiplied with all elements of residual"?
residual has 5021 rows and 32 columns. Do you want to create a product of all these elements?
Raisul Islam
2017 年 10 月 22 日
回答 (1 件)
KL
2017 年 10 月 22 日
It's a simple matrix multiplication, isn't it?
impulse_matrix = rand(32,32);
residue_matrix = rand(5021,32);
mult_result = residue_matrix*impulse_matrix;
12 件のコメント
Raisul Islam
2017 年 10 月 22 日
編集済み: Raisul Islam
2017 年 10 月 22 日
Andrei Bobrov
2017 年 10 月 22 日
Let impulse_matrix = [1 2;3 4]; residue_matrix = [1 2; 2 1; 1 3];. Please set result.
I feel like you'd want something like,
result = cumsum(residue_matrix,2)*prod(prod(impulse_matrix))
in this case, if you consider the matrices Andrei gave you, the result would be,
result =
24 72
48 72
24 96
Raisul Islam
2017 年 10 月 22 日
Raisul Islam
2017 年 10 月 22 日
編集済み: Raisul Islam
2017 年 10 月 22 日
KL
2017 年 10 月 23 日
With the first piece of code, I cannot clearly understand what you're doing but I would say you possibly could create your 3D matrix without using those 2 loops.
Then if you only have the Y data and you want to visualize, your can simply say
plot(your_y_data)
To make a sum along the third dimension, you just need
HDdim = sum(shock,3);
Raisul Islam
2017 年 10 月 23 日
KL
2017 年 10 月 23 日
What do you mean you don't need other two dimensions?
plot(HD(:,:,1)) %all rows and columns from page 1
plot(HD(1,:,1)) %first row, all columns from page 1
plot(HD(:,1,1)) %all rows, first column from page 1
If you want to concatenate certain row/column across all pages, do it like,
row_1_allpages = reshape(HD(1,:,:),1,size(HD,2)*size(HD,3))
Raisul Islam
2017 年 10 月 23 日
Raisul Islam
2017 年 10 月 23 日
col_1_allpages = reshape(HD(:,1,:),[],1)
Raisul Islam
2017 年 10 月 24 日
編集済み: Raisul Islam
2017 年 10 月 25 日
カテゴリ
ヘルプ センター および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!