for Loop Incremental Development Exercise
Write a for loop that does the following.
Start with any existing for loop, preferably one that sums a series, such as the one in section 3.8.
Test you code after you code each step in the process.
- Opens a figure for plotting.
- Sets the number of terms in the series to be n = 20
- Initializes series_sum = 0; % (Do not name the variable "sum", becuz that is a built-in MATLAB function.)
- Creates a for loop with index k = 1:n
- Computes termk = 3/(k^2)
- Adds termk to series_sum, and stores the result back into the series_sum variable.
- For each value of k, plots termk with the '*' marker.
- For each value of k, plots series_sum with the 's' marker.
- After the for loop, display the final values of termk and series_sum.
- Adds a title to the plot.
Add texts here. Do not delete this text first.