Am unable to wrap my head on this question regarding for loop , can someone explain the question and maybe write the code please.
조회 수: 1 (최근 30일)
이전 댓글 표시
댓글 수: 1
채택된 답변
Awais Saeed
2021년 11월 10일
Why use a loop if it can be done without it
A = [1 2 3; 4 5 6; 7 8 9];
[sum_of_elements] = halfsum(A)
function [sum_of_elements] = halfsum(M)
A = M;
sum_of_elements = sum(triu(A), 'all');
end
댓글 수: 4
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!