Built-in function for differentiation, MATLAB in Mathematics

Built-in function for Differentiation:

The MATLAB has a built-in function, diff that returns the differences between consecutive elements in a vector. For illustration,

>> diff([4 7 15 32])

ans =

3 8 17

For a function y = f(x) here x is a vector, and the values of f  '(x) can be approximated as diff(y) divided by diff(x). For illustration, the earlier equation can be written as an anonymous function.

>> f = @ (x) x .^ 3 + 2 .* x .^ 2 - 4 .* x + 3;

>> x = 1:3;

>> y = f(x)

y =

2 11 36

>> diff(y)

ans =

   9 25

>> diff(x)

ans =

   1 1

>> diff(y) ./ diff(x)

ans =

9 25

Posted Date: 10/22/2012 9:00:31 AM | Location : United States







Related Discussions:- Built-in function for differentiation, Assignment Help, Ask Question on Built-in function for differentiation, Get Answer, Expert's Help, Built-in function for differentiation Discussions

Write discussion on Built-in function for differentiation
Your posts are moderated
Related Questions
Dimensions - matrix: The size and length functions in the MATLAB are used to find array dimensions. Length function returns the number of elements in the vector. The size func

Common form of the switch statement: The common form of the switch statement is as shown below:   switch switch_expression   case caseexp1    action1   case cas

Applications of Customized Strings: Labels, Prompts, Arguments to Functions: The one of very useful application of this is to involve numbers in strings that are used to plot

Logical Vectors: The relational operators can also be used with the vectors and matrices. For illustration, let's say that there is a vector, and we want to compare each eleme

Illustration of Spreadsheet Files: This reads the numbers in a double vector variable nums and the text in a cell array txt (the xlsread function forever returns the numbers f


Symbolic Expression The solve function solves an equation and returns the solution(s) as symbolic expressions. The answer can be converted to numbers by using any numeric funct

Write a MATLAB function [d1, u1, l1, c1, r1] = NaiveGaussArrow(d, u, l, c, r) that takes as input the 5 vectors de ned above representing A. This function performs Naive Gauss redu

Refer the subset of a matrix: It is also possible to refer to the subset of a matrix. For illustration, this refers to the first & second rows, second & third columns: >> m

Illustration of Writing variables to a file: For illustration, in the below session in the Command Window, 3 variables are generated; these are then exhibited using who. Then,