How to half the value of a constant inside an iteration?
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Ahmad Hasnain
le 12 Fév 2019
Modifié(e) : Kevin Phung
le 12 Fév 2019
I have an iteration loop. Inside the loop, I have a constant gamma. I want its starting value to be 10e-8. I want to half its value on every iteration (10e-4 on second iteration). How to do it?
maxiter = 100;
while iter< maxiter
gamma = 1Oe-8
f = gamma * p;
end
4 commentaires
Réponse acceptée
Kevin Phung
le 12 Fév 2019
Modifié(e) : Kevin Phung
le 12 Fév 2019
maxiter = 100;
iter = 1;
x = 1:1:99;
n = 8*(1/2).^x; % n = 8 , 4, 2, 0.5,...
while iter< maxiter
gamma = 10 * 10^(-n(iter)); % 10e-8, 10e-4,...
f = gamma * p;
iter = iter + 1;
end
edit: changed x to 1:1:99 instead of 1:1:100
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Gamma Functions 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!