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

1 visualizzazione (ultimi 30 giorni)

Risposte (1)

Geoff Hayes
Geoff Hayes il 19 Mag 2020
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.

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by