Multiply Each Matrix in Cell Array by a Different Value
1 回表示 (過去 30 日間)
古いコメントを表示
I have a cell
A = {[1 2; 3 4]; [5 6; 7 8]};
and a vector
b = [1; 2]
and I want to multiply each matrix in A by the corresponding value in b. Is it possible to do that without loops?
0 件のコメント
採用された回答
James Tursa
2017 年 5 月 19 日
編集済み: James Tursa
2017 年 5 月 19 日
result = cellfun(@times,A,num2cell(b),'uni',false);
But this just moves the loops (which are part of cellfun) into the background.
2 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Multidimensional Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!