write a function to find maximum element of an array using recursion
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentar
Antworten (1)
Ameer Hamza
am 10 Sep. 2020
Bearbeitet: Ameer Hamza
am 10 Sep. 2020
Check my answer to this question: https://www.mathworks.com/matlabcentral/answers/591043-recursive-function-to-calculate-max-number
0 Kommentare
Siehe auch
Kategorien
Mehr zu Whos finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!