How to do (m,n,k) * (n,k) = (m,k) in matlab?

拥有回忆 提交于 2019-12-12 03:45:58

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!