フィルターのクリア

Find the summation of the outer elements of a rectangular matrix

3 ビュー (過去 30 日間)
Vinny
Vinny 2016 年 4 月 9 日
回答済み: Azzi Abdelmalek 2016 年 4 月 9 日
Using this matrix
a=[2 -3 1 0;5 7 1 -4;9 -6 0 2]
I need to find the sum of all the outer numbers in this matrix using loops and/or conditional statements. I have absolutely no idea on how to go about starting/doing this. Any help is appreciated, thank you.

回答 (2 件)

Andrei Bobrov
Andrei Bobrov 2016 年 4 月 9 日
a=[2 -3 1 0;5 7 1 -4;9 -6 0 2]
t = true(size(a))
t(2:end-1,2:end-1) = false
out = sum(a(t))

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 4 月 9 日
out=sum([a(1:end-1,1)' a(end,1:end-1) a(2:end,end)' a(1,2:end)])

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by