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

1 visualización (últimos 30 días)
Piyush Gupta
Piyush Gupta el 10 de Sept. de 2020
Editada: Ameer Hamza el 10 de Sept. de 2020
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

Respuestas (1)

Ameer Hamza
Ameer Hamza el 10 de Sept. de 2020
Editada: Ameer Hamza el 10 de Sept. de 2020

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by