Can someone do this calculation without for loops ?

 Respuesta aceptada

José-Luis
José-Luis el 15 de Jun. de 2016
Editada: José-Luis el 15 de Jun. de 2016
k = bsxfun(@times, a , reshape(b.^2,1,1,[]))
alt_k = bsxfun(@times, a , permute(b.^2,[3,1,2]))

1 comentario

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

Iniciar sesión para comentar.

Más respuestas (2)

Do you mean like this?
fun=@(a,b) b.*b*a
k = bsxfun(fun,a,b)
Azzi Abdelmalek
Azzi Abdelmalek el 15 de Jun. de 2016
Editada: Azzi Abdelmalek el 15 de Jun. de 2016
a = [1 2 3; 4 5 6];
b = [ 1 2 3];
bb=reshape(b.*b,1,1,[])
out=bsxfun(@times,a,bb)

Categorías

Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.

Preguntada:

el 15 de Jun. de 2016

Editada:

el 15 de Jun. de 2016

Community Treasure Hunt

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

Start Hunting!

Translated by