Use a for-loop for multiply colums of two arrays

2 views (last 30 days)
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 Comment
Torsten
Torsten on 19 May 2022
In the code above, you don't do anything that has to do with the question.

Sign in to comment.

Answers (1)

KSSV
KSSV on 19 May 2022
A = rand(4,8) ;
B = rand(4,1) ;
iwant = A.*B ;
  2 Comments
Julius Focke
Julius Focke on 19 May 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 on 19 May 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."

Sign in to comment.

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!