Returning the final value of a while loop
Mostra commenti meno recenti
I have a problem where I need to run a loop until x-y is less than a certain amount, with x getting smaller every time. When x-y is finally less than, say, h, how can I return the final value of x and put it into a variable? This is part of a larger function, and I don't want it to just display, I need to store the x value in a variable. For example:
function P = (x,y,h)
while (x-y) > h
x=x-1;
end
end
how can I make the answer to the function equal to the final x value?
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Loops and Conditional Statements in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!