Help with multiplication of cell arrays

Hi,
I have an array of 100 1*4 matrices
I have a second array of 1000 1*4 matrices
I want the .* of for each of my 100 matrices multiplied by each of the 1000 matrices.
In total, my ouput should be 100,000 matrics.
I just wanted some help with the code, I think i may be misunderstanding how the arrays are working...
Thanks

 採用された回答

Per
Per 2012 年 8 月 20 日

0 投票

Hi,
If I understood what you said correctly your problem could be solved like this
A = cell array containing 1000 1*4 matrices B = cell array containing 100 1*4 matrices
C = cell(length(A),length(B));
for i = 1:1000
for j = 100
C{i,j} = A{i}.*B{j};
end
end
the for loop could be vectorized to:
for j = 100
C{:,j} = A{:}.*B{j};
end
This will give you an output cell matrix of the size 1000*100
Hope this was of help.

2 件のコメント

John
John 2012 年 8 月 20 日
Thanks, perfect.
monu
monu 2014 年 5 月 6 日
this shows an error of... Undefined function 'times' for input arguments of type 'cell' . . plz help me for element by element multiplication ,subtraction ,addition,power,,,,

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

その他の回答 (1 件)

Sean de Wolski
Sean de Wolski 2012 年 8 月 20 日

0 投票

If you have the Neural Networks Toolbox:
And specifically
Cm = gmultiply(A',B);

1 件のコメント

Duvarakesh KR
Duvarakesh KR 2014 年 3 月 10 日
if i use this logic in my program.i got error like "Sparse integer array arithmetic operation in not supported" please help help

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

カテゴリ

ヘルプ センター および File ExchangeMatrix Indexing についてさらに検索

質問済み:

2012 年 8 月 20 日

コメント済み:

2014 年 5 月 6 日

Community Treasure Hunt

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

Start Hunting!

Translated by