Question

1. (10 points) Create an m-file called addup.m Use a for loop with k = 1 to 8 to sum the terms in this sequence: x(k) = 1/3 B

use MatLab to answer these questions

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

Hello

I am attaching all the required code here

For the last question , I have written the syntax for both the loop structures. You need to add your own comments. The basic difference between them can be found in any book or reference.

Regards

1.addup.m sumx=0; for k=1:1:8 x(k)=1/3.^k end for k=1:1:8 sumx=sumx+x(k); end disp(sumx); 2.ang180.m function f=ang180(a) if(a>180) f=a-360; elseif(a<-180) f=a+360; else f=a; end tester.m to use the function ang180 a1=ang180(-333); a2=ang180(177); a3=ang180(-177); a4=ang180(277); 3.findtheprimes.m z=primes(180); k=find(z>150 &z<180); l=length(k); fprintf('There are %d primes between 150 and 180\n',l); 4.whilevsfor.m for i=1:1:20 disp(i); end j=0; while(j<20) disp(j); j=j+1; end 
Add a comment
Know the answer?
Add Answer to:
use MatLab to answer these questions 1. (10 points) Create an m-file called addup.m Use a...
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
  • DO THIS IN MATLAB PLEASE DO THIS IN MATLAB Create a script file that performs the...

    DO THIS IN MATLAB PLEASE DO THIS IN MATLAB Create a script file that performs the following calculations. Your script will use the functions you create. Label all graphs appropriately. For this project, do not have your homemade functions fprintf anything, instead have all your fprintf commands within your script. Attach your published script file along with .m files for your functions. Exercise 1. A fundamental iterative method for finding the roots of equations of one-variable is known as Newton's...

  • Create a single script (.m file) to complete this assignment. Unless directed otherwise, use meaningful variable...

    Create a single script (.m file) to complete this assignment. Unless directed otherwise, use meaningful variable names for each variable: do not use the default variable ans to store your results. For this assignment do not suppress your output with semi- colons (). Each problem (ie. Problem 1. Problem 2, and Problem 4) should be in a separate cell, using the cell mode feature of MATLAB; the subparts should all be contained in the same cell as the parent problem....

  • Please answer question on MATLAB showing work and the script. Thank you. Create a function M-ile...

    Please answer question on MATLAB showing work and the script. Thank you. Create a function M-ile that will implement a for loop to perform the tollowing tasks for a random input array, tt x. Count how many elements are greater than an arbitrary integer and display these values as well as the count using fprintf. loop to perform the following tasks Create a function M-ile that will implement a for l for a random input array, x. Calculate the arithmentic...

  • (a) (4 points) Fill in the blanks in the following MATLAB function M file trap so...

    (a) (4 points) Fill in the blanks in the following MATLAB function M file trap so that it implements the composilu trapezidul rulo, using a soquence of w -1,2, 4, 8, 16,... trapezoids, to approximatel d . This M file uses the MATLAB built-in function trapz. If 401) and y=() f(!)..... fr. 1)). 3= ($1, then the execution of z = trapz(x, y) approximates using the composite trapezoidal rule (with trapezoids). (Note that the entries of are labeled starting at...

  • Urgent: Help with MatLab Program Create a Matlab function called seasonif. m which assigns to the...

    Urgent: Help with MatLab Program Create a Matlab function called seasonif. m which assigns to the numerical value of a month within the year a numerical value for the particular season in which that month occurs (see Table 2 above for numerical values to assign seasons). As usual, January is mouth 1, February is mouth 2, mid so on. Your function should allow decimal values (e.g. 4.68 should be considered part of April), but any value less than 1 or...

  • In MATLAB code please Problems 1. Create a script file called Lab10.m containing your work for...

    In MATLAB code please Problems 1. Create a script file called Lab10.m containing your work for the following problems to be uploaded to Canvas under Lab 10. 2. Create symbolic expressions for the following and display them using the pretty command ay 2c2 3. Create the following symbolic equations: 3 4. Factor the following expressions and collect like terms: ax2 - 18az+77a 42 +68x +240

  • Problem 1: Use MATLAB to create a script file and publish a pdf file for the...

    Problem 1: Use MATLAB to create a script file and publish a pdf file for the problem: Given that MX = Y, for the following matrices determine X using both matrix inversion and Gaussian elimination methods 7 -2 4.67 5 7 6.5 -8 13 Y = 13 Display results in short engineering format. Submit the published pdf file. Problem 2: Use MATLAB to create a script file and publish a pdf file for the problem: Given that MX = Y,...

  • Newton's Method in MATLAB During this module, we are going to use Newton's method to compute...

    Newton's Method in MATLAB During this module, we are going to use Newton's method to compute the root(s) of the function f(x) = x° + 3x² – 2x – 4 Since we need an initial approximation ('guess') of each root to use in Newton's method, let's plot the function f(x) to see many roots there are, and approximately where they lie. Exercise 1 Use MATLAB to create a plot of the function f(x) that clearly shows the locations of its...

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

  • Using mat lab to do it Create a single script file named yourname_While.m to answer the...

    Using mat lab to do it Create a single script file named yourname_While.m to answer the following problems. The file must be in cell mode to distinguish each problem. Make sure your script is nicely commented for each problem. Consider the following matrix of values: x =[345, 23, 17, 34, 85, 334, 111, 1067] Use a for loop and if statement to determine how many values greater than 30? Use fprintf to display the result. Repeat Problem 1., but use...

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