how to take the product of all the cells in a cell array in matlab

how can I take the product of all the cells of a cell array in Matlab? In my case, I have a cell array try_this with 125 cells. Each cell is a 3x3 matrix.

I would like to take the product over all of these matrices.

Is there a good way to do this?

Answers


It is possible to do this using a for-loop. The following collects the output piece-by-piece to the array result:

result = try_this{1}*try_this{2}; %// multiply first two cells
for k = 3:numel(try_this)
    result = result * try_this{k}; %// C{1}*C{2}* ... * C{k}
end

Edit: As discussed in the comments below, vectorizing such repeated matrix multiplication is not straightforward.


Need Your Help

Adding Line Height Drop Down to Tiny MCE Editor Tool Bar

tinymce editor

We are using BlogEngine.Net for managing blog posts which has implemented version “3.9.2” of Tiny MCE Editor.

C# Thread Queue Synchronize

c# threadpool queueuserworkitem

Greetings, I am trying to play some audio files without holding up the GUI. Below is a sample of the code: