Add a vector to a matrix and create a 3D array.
Mostra commenti meno recenti
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?
Risposte (1)
madhan ravi
il 6 Giu 2020
V = reshape(v,1,1,[]);
Wanted = bsxfun(@plus,V,M)
% or
Wanted = V + M % >= 2016b
1 Commento
Mats Høvin
il 15 Nov 2021
Thanks !!
Categorie
Scopri di più su Loops and Conditional Statements in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!