function [A]=AccGold()
n = 4;
while Gold(n)-Gold(n-1) > 0.00000001
n = n+1;
A = Gold(n)
end
end
I want to find the first value of Gold(n)-Gold(n-1) such that it is < 0.0000001

 채택된 답변

Walter Roberson
Walter Roberson 2016년 1월 25일
편집: Walter Roberson 2016년 1월 25일

0 개 추천

If the condition is immediately false you never assign to A.

댓글 수: 2

Joshua Hall
Joshua Hall 2016년 1월 25일
I want the loop to run until n is such that Gold(n)-Gold(n-1)<0.0000001, and then I want the value of Gold(n) at this n. Is there an easy way to change my function to do this?
Walter Roberson
Walter Roberson 2016년 1월 25일
Initialize A=Gold(n)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

질문:

2016년 1월 25일

댓글:

2016년 1월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by