问题
I have found this relevant question: Multiply columns of a matrix with 2d matrix slices of a 3d matrix in MatLab
I have the same problem but in my case m
can vary for each slice. Is there a way to do that with mtimesx ? Because m
varies, my 3d tensor is stored as a list of cells, each containing a matrix. Also my 2d matrix is rather a list of cells each containing a vector.
Is there a way I can do this multiplication without a for loop?
回答1:
Since your data is already stored in cellarrays, you can use cellfun
res = cellfun( @(x,y) x*y, mnkCell, nkCell, 'UniformOutput', false );
来源:https://stackoverflow.com/questions/15248109/how-to-do-m-n-k-n-k-m-k-in-matlab