Question

Using the X and Y values below, write a MATLAB function SECOND_DERIV in MATLAB. The output of the function should be the appr

Matlab please

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

function secDer = SECOND_DERIV(x)

X=[1,1.2,1.44,1.73,2.07,2.49,2.99,3.58,4.3,5.16,6.19,7.43,8.92,10.7,12.84,15.41,18.49];
Y=[18.89,19.25,19.83,20.71,21.96,23.6,25.56,27.52,28.67,27.2,19.38,-2.05,-50.9,-152.82,-354.73,-741.48,-1465.11];

%first derivative using forward difference   
dy=diff(Y)./diff(X);

%second derivative using forward difference
dyy=diff(dy);

%x values coresponding to 2nd derivatives in dyy
X=X(1:end-2);
%using interpolation to find the second derivation at any point
secDer= interp1(X,dyy,x,'linear','extrap');
%using extrap in case input x is beyond the range of X

- Function secDer = SECOND DERIV (x) X=[1,1.2,1.44,1.73,2.07,2.49, 2.99, 3.58, 4.3,5.16,6.19,7.43, 8.92,10.7, 12.84,1 Y=[18.8

Add a comment
Know the answer?
Add Answer to:
Matlab please Using the X and Y values below, write a MATLAB function SECOND_DERIV in MATLAB....
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
  • Using the X and Y values below, write a MATLAB function SECOND_DERIV in MATLAB. The output...

    Using the X and Y values below, write a MATLAB function SECOND_DERIV in MATLAB. The output of the function should be the approximate value for the second derivative of the data at x, the input variable of the function. Use the forward difference method and interpolate to get your final answer. X=[1,1.2,1.44,1.73,2.07,2.49,2.99,3.58,4.3,5.16,6.19,7.43,8.92,10.7,12.84,15.41,18.49]; Y=[18.89,19.25,19.83,20.71,21.96,23.6,25.56,27.52,28.67,27.2,19.38,-2.05,-50.9,-152.82,-354.73,-741.48,-1465.11];

  • 5. Create a MATLAB script to find the first and second derivative of given function using Forward, Backward, central an...

    5. Create a MATLAB script to find the first and second derivative of given function using Forward, Backward, central and Taylor numerical schemes. Test your code using the following functions: f(x)-xe*+3x2 +2x -1 and find f (3) and f' (3) for with h 0.1, 0.01 and 0.001 b. Approximate y'(1) and y"(1) using the following table f(x) 0.992 0.8 0.9 0.999 1.0 1.001 1.008 Input: (copy and paste the MATLAB or Scilab script in the following box) 5. Create a...

  • IN MATLAB Write a MATLAB function that can be used by a user to perform polynomial...

    IN MATLAB Write a MATLAB function that can be used by a user to perform polynomial interpolation using Lagrange Interpolation Method on a set of data. You should name your function as YourInitials_Lagrange_interpolation. 1. FUNCTION INPUT: . The input data pairs x and f(x) should be expressed as vectors and are used to construct the interpolation polynomials The interpolating data points/value The order of interpolating polynomials to be used. For this project you code should handle first order, second order...

  • Please help me answer this question using matlab Consider the function f(x) x3 2x4 on the...

    Please help me answer this question using matlab Consider the function f(x) x3 2x4 on the interval [-2, 2] with h 0.25. Use the forward, backward, and centered finite difference approximations for the first and second derivatives so as to graphically illustrate which approximation is most accurate. Graph all three first-derivative finite difference approximations along with the theoretical, and do the same for the second derivative as well

  • 8. Write a MATLAB function that will take as inputs a set of data (x,y) and...

    8. Write a MATLAB function that will take as inputs a set of data (x,y) and output the best estimate of the integral using a Romberg Array. The function should perform two trapezoidal integrations using the full interval and half the interval, and then combine these integrations in a Romberg Array. Your function should also output the relative error of the integral. Please note that the data entered may not be evenly spaced and your function should make sure that...

  • Using MATLAB Linear Interpolation: The following equation illustrates how to calculate an output for any input,...

    Using MATLAB Linear Interpolation: The following equation illustrates how to calculate an output for any input, using linear interpolation. The input must be within the bounds of the data set. The constants come from the data set; they are the nearest data points that bound the original input. (constants from data set--> y1, x1, y2) (output--> y) (input--> x) Create a MATLAB function file that calculates the linearly interpolated y-value (output) provided an x-value (input). The function should linearly interpolate...

  • MATLAB 1) Calculate the following for the function f(x) = e-4x- 2x3

    #use MATLAB script1)  Calculate the following for the function f(x) = e-4x- 2x3 a. Calculate the derivative of the function by hand. Write a MATLAB function that calculates the derivative 05. of this function and calculate the derivative at x = 0.5. b. Develop an M- to evaluate the cetered finite-difference approximation (use equation below), at x = 0.5. Assume that h = 0.1. c. Repeat part (b) for the second-order forward and backward differences. Again Assume that h = 0.1. d. Using the results...

  • Write a MATLAB script file that will find the values of X and Y required to...

    Write a MATLAB script file that will find the values of X and Y required to minimize the function f(x,y) = 30x + 60y + 40pi*y subject the constraining function g(x,y) = 2xy + (pi*y^2)/2 - 1600 using the method of the Lagrange Optimization Technique.

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

  • In MATLAB please Consider the nonlinear function: y = f(x) = x3 cos x a. Plot...

    In MATLAB please Consider the nonlinear function: y = f(x) = x3 cos x a. Plot y as a function of x as x is varied between -67 and 67. In this plot mark all the locations of x where y = 0. Make sure to get all the roots in this range. You may need to zoom in to some areas of the plot. These locations are some of the roots of the above equation. b. Use the fzero...

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