use for loop to write a sum function to achieve halfsum

조회 수: 1 (최근 30일)
paul mary
paul mary 2019년 1월 28일
답변: Stephan 2019년 1월 28일
this is a task of mooc course, please help me. It spent me a lot of time.
微信截图_20190128224908.png

채택된 답변

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

추가 답변 (0개)

카테고리

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