How to make faster row-wise Matrix multiplication ?

3 Ansichten (letzte 30 Tage)
Raihan Ul Islam
Raihan Ul Islam am 22 Apr. 2019
Kommentiert: Raihan Ul Islam am 22 Apr. 2019
Hi All,
I want to make my code run faster. I have to do row wise multiplication. But i do not want to use for loop.
For example
A =
11 11 6
7 11 9
2 2 2
4 11 5
7 11 11
B =
1 2 3
1 4 3
1 2 5
For i:1:5
A(i,:).*B
End
I want to skip the last for loop. As number of rows of A can grow upto 10,000
Any suggestion how to replace or make the code faster instead of using parfor?

Akzeptierte Antwort

Andrei Bobrov
Andrei Bobrov am 22 Apr. 2019
Bearbeitet: Andrei Bobrov am 22 Apr. 2019
Just use:
out = permute(A,[3,2,1]).*B;
  3 Kommentare
Andrei Bobrov
Andrei Bobrov am 22 Apr. 2019
I'm fixed my answer.
Raihan Ul Islam
Raihan Ul Islam am 22 Apr. 2019
Thanks a lot..

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Produkte


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by