Use a for-loop for multiply colums of two arrays

2 Ansichten (letzte 30 Tage)
Julius Focke
Julius Focke am 19 Mai 2022
Kommentiert: Jan am 19 Mai 2022
Hallo guys,
How can i multiply rows of two different arrays in a for loop?
So my starting point is a 4x8 (A) matrix and a 4x1 (B) matrix and I want to multiply point A(1x1) with B(1x1), A(2x1) and B(2x1) ... A(1x2) and B(1x1) etc.
I tried this: Mw(4x8) and m(4x1)
Steigung1_neu = zeros(1,8);
startWert = (1);
endWert = (8);
N1 = 1;
for index = startWert:1:endWert
Steigung1_neu(N1) = Mw(2,index)/m(2);
N1 = N1 +1;
end
This just multiplys every row, but I want to multiply every colum.
Would be nice, if you guys can give some tipps.
  1 Kommentar
Torsten
Torsten am 19 Mai 2022
In the code above, you don't do anything that has to do with the question.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

KSSV
KSSV am 19 Mai 2022
A = rand(4,8) ;
B = rand(4,1) ;
iwant = A.*B ;
  2 Kommentare
Julius Focke
Julius Focke am 19 Mai 2022
My problem is, that my posted code just multipies the rows, so the pointer goes the wrong way. I don´t know how yours should help.
Jan
Jan am 19 Mai 2022
What does "the pointer goes the wrong way" mean?
KSSV's answer solves: "multiply point A(1x1) with B(1x1), A(2x1) and B(2x1) ... A(1x2) and B(1x1) etc."

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by