Question

Use an anonymous function instead of a function file that calculates y(x) = sin(2x)( 4x2 +...

Use an anonymous function instead of a function file that calculates y(x) = sin(2x)( 4x2 + 3 ). Plot it using fplot, x goes from -8 to 8. Use your function to print out the value of y for x = -1.25 and x = 1.25.

Deliverables:

Script with anonymous function

Plot using fplot

Command window output

Step by Step Instructions:

Copy your calling script from Problem 1

Change the name of the function to be LabFcAnonymous (or something similar)

Write the LabFcAnonymous function BEFORE you call it

LabFcAnonymous = @(x) …

Remember to take the @ out of the fplot – you don’t need it because LabFcAnonymous is already a reference to a function

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

LabFcAnonymous = @(x)sin(2.*x).*(4*x.^2 + 3); %define anonymous function
fplot(LabFcAnonymous, [-8 8]) %use the function to calculate y from x = -8 to 8
y1 = LabFcAnonymous(-1.25) %print the value of function at x = -1.25
y2 = LabFcAnonymous(1.25) %print the value of function at x = 1.25

y1 = -5.5359 y2= 5.5359 @(x) sin (2.*x).* (4* x.2+3) 200 100 -100 -200- 300 -8 -6 -4 -2 2 4

Add a comment
Know the answer?
Add Answer to:
Use an anonymous function instead of a function file that calculates y(x) = sin(2x)( 4x2 +...
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
  • popcorn while using less paper to manufacture them. il l suript can help manufacturers of popcorn...

    popcorn while using less paper to manufacture them. il l suript can help manufacturers of popcorn tubs to optimize it to carry Q5. The polynomial y is defined as (20 points) y 2 x4-7 x3- 44 x92.5 x262.5 (a) In a script file, Initials_MT_Pb_05.m, define y using an anonymous function. (b) Use the anonymous function to evaluate y when x-3, x-0, x-3. (c) Use the anonymous function handle to plot y for-4sxS 5.5 Hint: Use fplot. (d) Use the plot...

  • 3. Consider the function f(x) = cos(x) in the interval [0,8]. You are given the following 3 point...

    3. Consider the function f(x) = cos(x) in the interval [0,8]. You are given the following 3 points of this function: 10.5403 2 -0.4161 6 0.9602 (a) (2 points) Calculate the quadratic Lagrange interpolating polynomial as the sum of the Lo(x), L1(x), L2(x) polynomials we defined in class. The final answer should be in the form P)a2 bx c, but with a, b, c known. DELIVERABLES: All your work in constructing the polynomial. This is to be done by hand...

  • Question: Hands-On Project 3-3 Use a Batch File A file with a bat file extension is...

    Question: Hands-On Project 3-3 Use a Batch File A file with a bat file extension is called a batch file. Yo... Use a Batch File A file with a .bat file extension is called a batch file. You can use a batch file to execute a group of commands, sometimes called a script, from a command prompt. Do the following to learn to use a batch file: 1. Using a command prompt window, copy the files in your Documents folder...

  • Please use matlab cars. Answer: Function file; Command Window: 5.4 Write a user-defined function that plots...

    Please use matlab cars. Answer: Function file; Command Window: 5.4 Write a user-defined function that plots a circle given the coordinates of the center and the radius. For the function name and arguments use circleplot(x,y,R). The input arguments are the and y coordinates of the center and the radius. Use linspace to generte the angle from 0 to π with 100 points. (Hint: the circle equation: x+Rcos and yy-yRsin 0.) This function has no output arguments. Plot the circle using...

  • Please show the code necessary, and explanations on MATLAB. Plotting 11) Plot the function y =...

    Please show the code necessary, and explanations on MATLAB. Plotting 11) Plot the function y = sin(x) from x = 0 to 21. 12) Plot the functions y = x2 z = x2 + 2x + 1 from x = 0 to 2 on the same graph. Scripts: Input and Output 13) Write a script (M-file) to read in a message at the command line using the MATLAB input function and then display the message to the Command Window using...

  • 3. (a) Write a MatLab program that calculates for the function F(x, y) = ln(x + Va,2-y2) The prog...

    3. (a) Write a MatLab program that calculates for the function F(x, y) = ln(x + Va,2-y2) The program should use pretty) to display both the original function and the differentiated result, and also use fprintf() to print a label such as "F(x,y) -" and "dF/dxdy - " in front of both the function and the derivative. Then have your program also print out the derivative again after it uses simplify() on the result (b) Find the Taylor expansion of...

  • 4. The first derivative of a function f(x) at a point x = xo can be approximated with the four-po...

    Solve using MATLAB and provide code please 4. The first derivative of a function f(x) at a point x = xo can be approximated with the four-point central difference formula: dx 12h where h is a small number relative to xo. Write a user-defined function function that calculates the derivative of a math function fx) by using the four-point central difference formula. For the user-defined function name, use dfax-FoPrder(Fun, x0), where Fun is a name for the function that is...

  • efficients Wi for the signal w(t) sin(16rt) 14. (8 pts) Determine the FS coefficients W, for the signal w(t) 3 cos(12rt)-5 sin(16rt). (c) (9 pts) Suppose a MATLAB anonymous function X already...

    efficients Wi for the signal w(t) sin(16rt) 14. (8 pts) Determine the FS coefficients W, for the signal w(t) 3 cos(12rt)-5 sin(16rt). (c) (9 pts) Suppose a MATLAB anonymous function X already exists that correctly defines X() Write MATLAB code that uses X to reconstruct and then plot a 10-periodic replication of e(t) over-10sts10. efficients Wi for the signal w(t) sin(16rt) 14. (8 pts) Determine the FS coefficients W, for the signal w(t) 3 cos(12rt)-5 sin(16rt). (c) (9 pts) Suppose...

  • Don't use fplot command. Matlab code. Write out code please, don't make it a screenshot. 2....

    Don't use fplot command. Matlab code. Write out code please, don't make it a screenshot. 2. Use the subplot command to make two plots of the function f(x) = (x + 1)(x - 2)(2x – 0.25) - et one graph for 0 < x <3 and the other for 3 < x < 6. Use a logarithmic scale for the y-axis. Include a plot title (for each subplot), and label both aris(for each subplot).

  • I. For the function. /(x) -X-4X+2XY+2Y+2Y+14 a. Plot the surface function for X over [5 6]. and Y...

    Please use matlab for the following problem I. For the function. /(x) -X-4X+2XY+2Y+2Y+14 a. Plot the surface function for X over [5 6]. and Y over [-4, -2]. ecolour plot for X over [O 101 and Yover [43] and values for the contours of V [1 1.25 1.5 22.5 3] c. Write an m-file to find the minimum of the function using the gradient descent method Use a starting value of [4, -4]. I. For the function. /(x) -X-4X+2XY+2Y+2Y+14 a....

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