フィルターのクリア

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