write a function to find maximum element of an array using recursion

6 visualizzazioni (ultimi 30 giorni)
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

Risposte (1)

Ameer Hamza
Ameer Hamza il 10 Set 2020
Modificato: Ameer Hamza il 10 Set 2020

Categorie

Scopri di più su Matrices and Arrays in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by