Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Multiply each number in a matrix by the diagonal number of a given row using a for loop

조회 수: 1 (최근 30일)
Vinny
Vinny 2016년 4월 24일
마감: MATLAB Answer Bot 2021년 8월 20일
I have this matrix here
a=[2 -5 7;1 1 3;4 5 12];
I need to multiply each of the numbers in the row by the diagonal of that row using a for loop. So afterwards it should look like this
a=[4 -10 14;1 1 3;48 60 144]
I have no idea on how to do this, so any help on how to do this is appreciated, thank you.

답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2016년 4월 24일
편집: Azzi Abdelmalek 2016년 4월 24일
a=[2 -5 7;1 1 3;4 5 12];
b=bsxfun(@times,a,diag(a))

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by