clc;
clear;
close all;
sum = 0;
max = 100000;
k = 0;
while (sum < max)
k = k+1;
sum = sum + (5*k^2 - 2*k);
if sum > max
n = k-1;
sum = sum - (5*k^2 - 2*k);
break
end
end
fprintf('The number of terms is %g and its sum is %g
\n',n,sum);
In MATLAB Write a script to determine the number of terms required for the sum of...
Convince yourself that the Maclaurin Series for cos(x) is: A. Write a function script called cos_series that takes that takes as its inputs, x and N and has output given by the sum in the N-term Maclaurin Series approximation for Cos(x). Hint: try a “for loop” and set “format long” in your code. You may use the MATLAB built-in function factorial() B. Check your code by finding the 2-terms, 3-terms, 4-terms, 5-terms and 6-terms Maclaurin Series approximations every 30 degrees...
Solve using Matlab Write a simple loop to list the squares of the first 10 integers. Using a simple "while" loop, write a script to sum the series 1 + 2 + 3 + ... such that the sum is as large as possible without exceeding 100. The program should display how many terms are used in the sum. Write a script that takes as input an integer n and creates the n*n matrix A with (ij)th component given by...
Use a while-end loop in a script file to calculate the sum of the first n terms of the series: sigma_k=1^n (-1)^kl^2 + 5k/3^k. Show the script file and the two results of n = 10 and n = 20. (b) Use a for-end loop in a script file to calculate the sum of the first n terms of the series: sigma_k=1^n (-1)^kl^2 + 5k/3^k. Show the script file and the two results of n = 10 and n =...
x) -1-2! +41-614 (2k)! k=0 he actual Write a script that will determine how many terms are needed in the series to get the error between t value and the estimate to be less than 0.0001. The user should input the value of x and a formatted print statement should be used to display the result. Use a while loop to complete this problem. Note: error I(cos 2x)actual - (cos 2x)estimatel. See below for an example. Enter a value of...
.using while loops(matlab) Write a program to display the sum of the series [ 9 + 99 + 999 + 9999 ...] Test Data : Input the number or terms :5 Expected Output : 9 99 999 9999 99999 The sum of the series = 111105
write matlab script 5. Use a for loop to sum the elements in x = [1 2 3 4 5] Check your answer with sum function 6. Use a while loop to sum the elements in x = [1 2 3 4 5] Check your answer with sum function
Using MATLAB code only please! 4. Write a script which does the following (use a while loop). a. Creates a random number b. Calculates the sum of random numbers selected, across all loop iterations c. Prints the number of random numbers (the number of loop iterations) which were required to add up to 20 (or more).
run/call tle un/cd to compute the sum of the first 15 terms of the series: th (b) It is desired 14 n3 - 20 n2 + 5n, 110) 1,2,..15 n Develop a pseudocode of the required program. roposed algorithm in a flow chart if it is solved using a for loop ow the p () Write a MATLAB script file using for loop run/call tle un/cd to compute the sum of the first 15 terms of the series: th (b)...
THE CODE NEEDS TO BE ON MATLAB 2. Exercise (a) Let's write a script file that calculates exp(2) by a Maclaurin series using a while loop exp x )=-+-+-+-+ The while loop should add each of the series terms. The program error as defined below is smaller than 0.01. Error is the exact value (i.e. exp(2)), minus the approximate value (i.e., the current series sum) should exit the loop when the absolute absolute error-lexact-approx Use fprintf within the loop such...
1) Write a MATLAB script to prompt a user to input two numbers, then assess whether the two numbers are equal or not. If the two numbers are equal, display that they are equal in the Command Window. If they are not equal, display that they are not equal in the Command Window. 2) Write a MATLAB script that prompts the user to enter the day of the week using the input function. If the information the user enters is...