Add a vector to a matrix and create a 3D array.
8 ビュー (過去 30 日間)
古いコメントを表示
Without using for loop, how can I add a row or column vector V to a 2D matrix M and create a 3D array A with ith page of the array is calculated by (V(i) + M).
Is bsxfun always faster than for loop?
0 件のコメント
回答 (1 件)
madhan ravi
2020 年 6 月 6 日
V = reshape(v,1,1,[]);
Wanted = bsxfun(@plus,V,M)
% or
Wanted = V + M % >= 2016b
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!