Can someone do this calculation without for loops ?
Ältere Kommentare anzeigen
a = [1 2 3; 4 5 6];
b = [ 1 2 3];
for n = 1: size(a,1)
for m = 1:size(a,2)
k(n,m,:)= b.*b*a(n,m)
end
end
Akzeptierte Antwort
Weitere Antworten (2)
Joakim Magnusson
am 15 Jun. 2016
Do you mean like this?
fun=@(a,b) b.*b*a
k = bsxfun(fun,a,b)
Azzi Abdelmalek
am 15 Jun. 2016
Bearbeitet: Azzi Abdelmalek
am 15 Jun. 2016
a = [1 2 3; 4 5 6];
b = [ 1 2 3];
bb=reshape(b.*b,1,1,[])
out=bsxfun(@times,a,bb)
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!