Add a vector to a matrix and create a 3D array.
조회 수: 7 (최근 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!