Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please solve this problem using matlab 10:18 AM 89% Matlab_Exercises.pdf Programming in MATLAB: Scripts and Functions EXERCISES 1. A script file to compute sine series:

image text in transcribed
image text in transcribedPlease solve this problem using matlab
10:18 AM 89% Matlab_Exercises.pdf Programming in MATLAB: Scripts and Functions EXERCISES 1. A script file to compute sine series: Write a script file named sineseries.m that computes the value of sin() at a given a using, n terms of the series expansion of the sine function: Follow the steps given below First, query MATLAB to see if the name sineseries is already taken by some variable or function with the command exist ('aineseries). What does the MATLAB response mean? [Hint, see on-line heip on exist.] Include the following line as the header (H1 line) of your script file. %SINESERIES: computes sin(x) fron series expansion Now code the formula so that it computes the sum of the series for a given scalar x and a given integer n . Save the file. Type help sineseries to see if MATLAB can access your script file. Now, compute sin(/6) with n 1,5, 10, and 20. Compare the results. Do the same for some other x of your choice. 2. A function file to compute sine series: Take the script file written above and convert it into a function file using the following steps. . Name the function sine series and modify the HI line appropriately. . Let z and n be the input to your function and y (the sum) be the output. Save the function and execute it to see that it works and gives the same output as the script file above. Modify the function to include more on-line help on how to run the function. . Modify the function so that it can accept a vector and give an appropriate 3. . Modify the function to include a check on the input n. The function should proceed only ifn > 0 is an integer, otherwise it should display an error message. Provide for an optional output err, which gives the % error in y when compared to sin(x). Hint: use conditional statement on nargout for optional output.) . Modify the function so that it takes a default value of n 10 if the user does not specify n. Hint: use nargin.] . Execute the function to check all features you have added

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Development For Dummies

Authors: Allen G. Taylor

1st Edition

978-0764507526

More Books

Students also viewed these Databases questions