Add a vector to a matrix and create a 3D array.

6 vues (au cours des 30 derniers jours)
AA
AA le 6 Juin 2020
Commenté : Mats Høvin le 15 Nov 2021
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?

Réponses (1)

madhan ravi
madhan ravi le 6 Juin 2020
V = reshape(v,1,1,[]);
Wanted = bsxfun(@plus,V,M)
% or
Wanted = V + M % >= 2016b

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by