Question

Write a MATLAB code to compute the summation of the integers from 1 to 1000 by...

Write a MATLAB code to compute the summation of the integers from 1 to 1000 by using for-end loop command. Your code should display the value of the summation within the following statement (using fprintf command): The value of the summation of the integers from 1 to 1000 is ???.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

code

sum = 0;
for c = 1:1000
sum = sum + c;
end
fprintf('The value of the summation of the integers from 1 to 1000 is = %d',sum);

Add a comment
Know the answer?
Add Answer to:
Write a MATLAB code to compute the summation of the integers from 1 to 1000 by...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • THIS IS USING MATLAB 1. The value of a can be approximated by: a. Write a...

    THIS IS USING MATLAB 1. The value of a can be approximated by: a. Write a script which asks the user to input the number of iterations (n), then computes the expression, using a for loop to compute the summation with the specified number of iterations. The larger the number of iterations, the closer the result should be to it. Print out the value of n, and the result using fprintf with 8 digits after the decimal to see the...

  • MATLAB CODE. answer the following question in a driver in matlab please. 3. Write a for...

    MATLAB CODE. answer the following question in a driver in matlab please. 3. Write a for loop that calculates the first eleven values of the recursive sequence ak = -1(1 - ax-1), do = 10, and stores all eleven numbers in a vector. After the loop write a command to display the vector in the command window. Note that your loop does not need to compute do since this is given, and we should be the first entry in your...

  • Write a MATLAB code to generate an array of 100 random integers between 1 and 10...

    Write a MATLAB code to generate an array of 100 random integers between 1 and 10 using the command “randi”. Using “if” statement, impose the condition that if a number in the array is greater than 5, the number is modified as, number = number – 11. Find the sum of the array and store it. Repeat this exercise for 10, 1000 and 100000 trials and plot the following: (a) Sums obtained vs trails number (b) Histogram of the sum...

  • 1. (30 Points) Write a MATLAB program that displays "The multiplication of 10 multiplied by integers...

    1. (30 Points) Write a MATLAB program that displays "The multiplication of 10 multiplied by integers of 1 through 15. Display your result back to the user with 2 decimal places (yes, 2 decimal places). You must implement your code using a for loop. The result should have the following format: The multiplication of 10*1 =10.00 The multiplication of 10*2 =20.00 The multiplication of 10'3=30.00 The multiplication of 10*15=150.00 2. (35 Points) Write MATLAB code to prompt a user for...

  • MATLAB Code: ?MATLAB Code: Write a function that converts a given letter grade it will print...

    MATLAB Code: ?MATLAB Code: Write a function that converts a given letter grade it will print its equivalence in numerical scale. For example if the user enters A, then your function should print a message stating that the grade must be between 90 and 100. B is between 80 and 89, etc. Everything under 60 is F. Use the switch-case function. Use fprintf to display the results on the screen.

  • THE CODE NEEDS TO BE ON MATLAB 2. Exercise (a) Let's write a script file that...

    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...

  • Write a MATLAB code that has two inputs from the user (two numbers) and display the...

    Write a MATLAB code that has two inputs from the user (two numbers) and display the summation result of these numbers?

  • Use in MATLab (b) Write a computer program to calculate ex as an approximate series summation, to an accuracy of 101...

    Use in MATLab (b) Write a computer program to calculate ex as an approximate series summation, to an accuracy of 1010. The value of x should be supplied to the program with the "input" command. Do not run the program. (b) Write a computer program to calculate ex as an approximate series summation, to an accuracy of 1010. The value of x should be supplied to the program with the "input" command. Do not run the program.

  • Using Matlab can you please write the code for question 5. Display the zl and 22...

    Using Matlab can you please write the code for question 5. Display the zl and 22 results using the table function. 5. Create an anonymous function (name it perm) to determine how many arrangements of a subgroup n are possible from a total group size of m when the order is important (permutations). Test the function with m= 10 and n 3 . Use an fprintf statement to display the answer

  • Need help with MATLAB, what code should be added to print the graph of the trapezoid rule code be...

    Need help with MATLAB, what code should be added to print the graph of the trapezoid rule code below? %%Matlab code for Question 5. syms X y intlx exp(x),0,2); %integration of x*exp(x) fprintf("htlntegration of x"2*exp(x) for [O 3] is %2.5f.\n,y) %Integration using Trapizoidal rule nn [100 1000]; for ii 1:2 a:0; b-3; %Integration limit ns-1:nn(i) integral Values-zeros(size(ns)); ourFunction-@(x) x.*2.*exp(x); for n-ns val(n)-trapizoidal (ourFunction,a,b,nn(i); end fprintf nlntegration of x 2*exp(x) using Trapizoidal rule for [O 3]\n') fprintf('1tTrapizoidal integration value for n-%d...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT