Multidimensional array multiplication issue

11 ビュー (過去 30 日間)
Raisul Islam
Raisul Islam 2017 年 10 月 22 日
編集済み: Raisul Islam 2017 年 10 月 25 日
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
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
Raisul Islam 2017 年 10 月 22 日
Thank you for your response KL. Impulse matrix must be multiplied in response matrix. So first each row of impulse matrix will be multiplied with the entire residual matrix. Then the second row of the impulse matrix will be multiplied with entire residual matrix. These two steps will be added. And then the third row will be multiplied with residual and added to first two stages. The output will have 5021 rows and 32 columns. I am checking the impact of impulse matrix on the entire residual matrix. This must be done with nested loops. I need to plot the 5021 rows for 32 variables. I will really appreciate your suggestion.

サインインしてコメントする。

回答 (1 件)

KL
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 件のコメント
KL
KL 2017 年 10 月 24 日
編集済み: KL 2017 年 10 月 24 日
col_1_allpages = reshape(HD(:,1,:),[],1)
Raisul Islam
Raisul Islam 2017 年 10 月 24 日
編集済み: Raisul Islam 2017 年 10 月 25 日
KL mate, with result = cumsum(residue_matrix,2)*prod(prod(impulse_matrix))
for some reason I get 0 kin all elements of output matrix. I tried this way,
impulse=impulse(:); residual=v; [m,n]=size(v); HD=[];
for i=1:m
for j=1:n
HD = impulse(:).*v(i);
end
end
GHD=zscore(HD);
The problem is with the for loop I get the output for the first column only. So I get HD= p by 1 matrix. I want HD =p by 32 matrix. Currently, my impulses elements are multiplied with elements with the rows for the first column only. What modification should I do here to have all elements of impulse to be multiplied with all other columns just as it does for the first column in this loop. So I just need the same operation executed across all columns of v. What might be the nested loop? I appreciate your skilled solutions. As you see I am a new user, you are helping a lot.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by