Use a for-loop for multiply colums of two arrays

조회 수: 1 (최근 30일)
Julius Focke
Julius Focke 2022년 5월 19일
댓글: Jan 2022년 5월 19일
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
Torsten
Torsten 2022년 5월 19일
In the code above, you don't do anything that has to do with the question.

댓글을 달려면 로그인하십시오.

답변 (1개)

KSSV
KSSV 2022년 5월 19일
A = rand(4,8) ;
B = rand(4,1) ;
iwant = A.*B ;
  댓글 수: 2
Julius Focke
Julius Focke 2022년 5월 19일
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 2022년 5월 19일
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."

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by