i did this but cant sure about my howemork question 2. can anyone help me?

조회 수: 1 (최근 30일)
Emre HAMZACEBI
Emre HAMZACEBI 2020년 5월 19일
답변: Geoff Hayes 2020년 5월 19일

답변 (1개)

Geoff Hayes
Geoff Hayes 2020년 5월 19일
Emre - the question is asking you to write a function called threshold that determines the number of terms required for the sum of the series (see pdf) to exceed an input variable called limit. That means that you need to keep summing up your terms until that sum exceeds the limit
if summa > limit
break;
end
You probably don't want to use a for loop since you don't know how many iterations are necessary until that limit is exceeded. Also, in your code, you use k as your for loop step variable and also use it to for a calculation. It isn't always a good idea to re-use variables in this way as it could lead to unpredictable results so consider using a different variable name (for one of these two) or just move the calculation to the line of code where you update the sum.

카테고리

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