Getting a function error "Output argument "z" (and maybe others) not assigned during call"
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Ramy El Bazi
le 1 Nov 2016
Modifié(e) : Alexandra Harkai
le 1 Nov 2016
Hey guys im new to matlab ive been trying to do a power function but I've been getting this error and Im not understanding why
Here is the function
function [z] = power1(x,y)
if y>=0
if y==0
z=1;
end
if y==1
z=x;
end
z=x*power1(x,y-1);
end
end
0 commentaires
Réponse acceptée
Alexandra Harkai
le 1 Nov 2016
Modifié(e) : Alexandra Harkai
le 1 Nov 2016
If y<0, variable z doesn't get any value assigned to it.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Get Started with MATLAB dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!