write a function to find maximum element of an array using recursion
조회 수: 1 (최근 30일)
이전 댓글 표시
function mx = recursion_max(v)
n=size(v);
if size(v) <2
mx = v(1);
else mx = max(recursion_max(v(n-1)), mx );
end
end
답변 (1개)
Ameer Hamza
2020년 9월 10일
편집: Ameer Hamza
2020년 9월 10일
Check my answer to this question: https://www.mathworks.com/matlabcentral/answers/591043-recursive-function-to-calculate-max-number
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!