Matlab while loops with equations

조회 수: 11 (최근 30일)
Trey  Godfrey
Trey Godfrey 2022년 5월 4일
답변: James Tursa 2022년 5월 4일
Does anyone know how I would start to write this i undersand I should be using while loops to run through the fomula but don't know where to go from there

답변 (1개)

James Tursa
James Tursa 2022년 5월 4일
You should probably go through the online tutorials for learning MATLAB. But I will give you an outline to get started:
tolerance = _____; % the tolerance to use for stopping condition
difference = _____; % an arbitrary number that is >= tolerance (so you get inside the while loop below)
n = 1; % the starting value of n
one_over_e = _____; % the intial estimate of 1/e (an expression involving n)
while( difference >= tolerance )
_____ % PUT CODE IN HERE TO INCREMENT n, calculate a new estimate, calculate the new difference, etc.
end
_____ % PUT CODE HERE TO PRINT RESULTS
You need to fill in the blanks

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by