use for loop to write a sum function to achieve halfsum

1 view (last 30 days)
this is a task of mooc course, please help me. It spent me a lot of time.
微信截图_20190128224908.png

Accepted Answer

Stephan
Stephan on 28 Jan 2019
Hi,
note the triu function:
A = [1 2 3; 4 5 6; 7 8 9]
result = sum(triu(A),'all')
Best regards
Stephan

More Answers (0)

Categories

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

Tags

Community Treasure Hunt

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

Start Hunting!