matrix in a cell multiplicaiton

1 vue (au cours des 30 derniers jours)
Jing Hua
Jing Hua le 10 Juil 2012
I got two cells and each cell contain three matrix.
{matrix_1 matrix_2 matrix_3}and {matrix_4 matrix_5 matrix 6}
I want to multiply two matrix together in a matrix-wise fashion, NOT element wise by using 'cellfun'.
I was wondering if cellfun(@(v,w) v*w,cell1, cell2.'un',0) is correct, does it compute in a matrix wise fashion?
Cheers
Jing
  2 commentaires
Luffy
Luffy le 10 Juil 2012
Maybe you wrote it in a hurry but change it to cellfun(@(v,w) v*w,cell1, cell2,'UniformOutput',0)
Jan
Jan le 10 Juil 2012
@Jing Hua: I suggest that you try it and check the results.

Connectez-vous pour commenter.

Réponse acceptée

Jan
Jan le 10 Juil 2012
Yes, I like CELLFUN also. But if it causes troubles, why not using a loop?
Result = cell(size(cell1));
for i = 1:numel(cell1)
Result{i} = cell1{i} * cell2{i};
end
I assume this runs even faster then CELLFUN, but I cannot test this currently. Without doubt it is faster to write and to debug.

Plus de réponses (0)

Catégories

En savoir plus sur Cell Arrays dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by