Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

?MATLAB? HW7P4 (30.points)+ (15 pts) Referring to P2 to P4 of HW6. You are required to develop three functions MySin, MyCos and MyExp. You can

?MATLAB?

image text in transcribed

HW7P4 (30.points)+ (15 pts) Referring to P2 to P4 of HW6. You are required to develop three functions MySin, MyCos and MyExp. You can use the sum of the infinite series as you did in HW6P4 using a precision of eps for each function. The following are infinite series representations of the functions sine and cosine along with the exponential. + 2n+1 sin(x) = ?(-1)" cos(x) - > (-1)" (2n)! n=0 c0 7 n! To perform the summation, use a conditional while loop using the constant, eps, as your precision.*- Your functions must be able to work on scalars, vector or 2D matrices. This can be done using nested for loops to scan every element of the input array and use it as the value of x in the infinite series. Your functions must return an array of the same size as the input array where every element of the output array will be either the sine, the cosine or the exponential of every element of the input array and at the same position (row, column).* For example, if the input array is [Qpi/6 pi/3 pi/2 must be in the form [0 0.5000 0.8660 1.0000 (5 pts) Use your functions in the command window to determine the following:* ], the output of MySin function a) sin(n/3): sin([-? -?/2 0 ?/2 ?])+' b) cos(?/3), cos(-? -?/2 0 ?/2 ?]) c) e-2; exp([-5-3-1 2 4)- d) sin(A), cos(A), exp(A) where A i:pi/3:pi;-pi/2:pi/3:3*pi/2;- Compare the results of your functions for parts a) to d) with that determined using the built in MATLAB functions sin, cos and exp.* (10 pts) Write a script file HW7P4.m that uses your functions to produce:* One plot of the sine and cosine curve together in the interval-2? to 2?. You can use either the plot command with 100 points or the fplot () function. Use different line styles and annotate your plot.*' Another plot in a new figure window with 2 subplots in one column. The upper plot is your exponential function in the range 0.1 to 10 with linear scale for both the x and y axis. The lower plot is the same function with logarithmic scale for the y axis only

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

Climate And Environmental Database Systems

Authors: Michael Lautenschlager ,Manfred Reinke

1st Edition

1461368332, 978-1461368335

More Books

Students also viewed these Databases questions

Question

Have you ever been arrested for a crime?

Answered: 1 week ago

Question

10:16 AM Sun Jan 29 Answered: 1 week ago

Answered: 1 week ago

Question

3. Identify challenges to good listening and their remedies

Answered: 1 week ago

Question

4. Identify ethical factors in the listening process

Answered: 1 week ago