Question

Task 6: A forward difference for Numeric differentiation Routine (7 pts) Use Mat Lab to write a function called forwarddiff.m that takes data sample locations and function san plings at those locations as inputs and returns an approximation of the derivative at the sample points based on forward finite difference method with order of accuracy o(h). The function should display nothing to the screen unless an error or warning occurs. The detailed specification is as follows: The approximation of derivative by forward difference method (for o(hs) is given as: f (x) 6h Valid call: I forwarddiff(x, fx) x (N-element vector) numerical data for san ple locations. Inputs fx (N-element vector) function data taken at locations defined in input x. Approximation for the first derivative of fx at data points 2 to N-2. output Assumptions The is element of x corresponds to the i element of fx. Validation: Your code should throw an error if any of the following are true x and fx are not the same length either of the inputs are not vectors (e.g., a matrix) either of the inputs contains something other than numerical data Hint: functions like isvector() and isnumeric may come in handy during input validation Do not call any specialized Matlab functions that perform differentiation. Write it from scratch.

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

Hi

I didn't find any question here. It is suggested to post a valid question more specifc and detailed.

Check the content before you post.

Thanks

Add a comment
Know the answer?
Add Answer to:
Use Mat Lab to write a function called forwarddiff.m that takes data sample locations and function...
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
  • (10 pts) Write a function to call python modules (either re-write or re-use the program you...

    (10 pts) Write a function to call python modules (either re-write or re-use the program you developed before) to calculate the derivative of In(1+x) at X = 1 using the forward difference, central difference and extrapolated dif- ference methods. Also use this function to create a similar log-log plot that compares the absolute value of the approximation error (you can ignore the rounding error) as a function of the size of the intervals used for these three methods. Choose the...

  • Write a Matlab function called sine_Taylor that inputs a positive integer n, a number x, and...

    Write a Matlab function called sine_Taylor that inputs a positive integer n, a number x, and outputs the nth Taylor polynomial of the sine function. Compute the absolute and error for n = 1: 10 at x = 1, obtained by comparing the output of your function to that of Matlab's built in sine function. Type on the Matlab console format long, then compute the previous error. Repeat the operation by typing format short. Comment on the result (quantify the...

  • [MATLAB] Write a function called myMultProd.m that computes the cumulative product of the elements in a...

    [MATLAB] Write a function called myMultProd.m that computes the cumulative product of the elements in a vector. The cumulative product, pj, of the jth element of the vector x, xj, is defined by pj = (x1)(x2) … (xj) for j = 1:length of the vector x. DO NOT USE CUMPROD For example, when you run your function it should look like this: >> x = [2 3 4 2]; >> myMultProd(x) >> ans = 2 6 24 48 That is,...

  • The problem demonstrates the use of the random number generator to recover previously generated random numbers Write a function called randi test that takes two scalar positive integer arguments maxi...

    The problem demonstrates the use of the random number generator to recover previously generated random numbers Write a function called randi test that takes two scalar positive integer arguments maxi and n, and retums two output arguments: a row vector of n2 elements and and n-by-n matrix. The two output arguments must contain the exact same set of random integers that fall between 1 and maxi Do this using the random number genertor, not by reshaping the data Example n,v-randi...

  • Using C++ to write .cpp and .h file. Main function and sample output are given. The...

    Using C++ to write .cpp and .h file. Main function and sample output are given. The task is to write a vector class for dynamic allocation.declare the the class named vector with the required attributes. The task are defined in the main function. #include <iostream> #include "vector.h". #define LOG(x,y) std::cout << x << y « std::endl; #define INFO(x) std::cout << "[INFO]: #define WARNING(x) std::cout <« "[WARNING]: "<< x <« std: :endl; << x << std::endl; " « x < std::endl;...

  • MATLAB Create a function that provides a definite integration using Simpson's Rule Problem Summar This example demo...

    MATLAB Create a function that provides a definite integration using Simpson's Rule Problem Summar This example demonstrates using instructor-provided and randomized inputs to assess a function problem. Custom numerical tolerances are used to assess the output. Simpson's Rule approximates the definite integral of a function f(x) on the interval a,a according to the following formula + f (ati) This approximation is in general more accurate than the trapezoidal rule, which itself is more accurate than the leftright-hand rules. The increased...

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