Can someone do this calculation without for loops ?

 Réponse acceptée

José-Luis
José-Luis le 15 Juin 2016
Modifié(e) : José-Luis le 15 Juin 2016
k = bsxfun(@times, a , reshape(b.^2,1,1,[]))
alt_k = bsxfun(@times, a , permute(b.^2,[3,1,2]))

1 commentaire

Amelos
Amelos le 15 Juin 2016
this one works also , thanks k = reshape(kron(b.*b,a),[size(a),numel(b.*b)]);

Connectez-vous pour commenter.

Plus de réponses (2)

Azzi Abdelmalek
Azzi Abdelmalek le 15 Juin 2016
Modifié(e) : Azzi Abdelmalek le 15 Juin 2016
a = [1 2 3; 4 5 6];
b = [ 1 2 3];
bb=reshape(b.*b,1,1,[])
out=bsxfun(@times,a,bb)

Catégories

En savoir plus sur Mathematics dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by