MATLAB Integration and Derivatives MATLAB Derivatives The MATLAB
MATLAB Integration and Derivatives
MATLAB Derivatives The MATLAB command for creating a line graph is diff. General Form: diff computing symbolic derivatives. % First Order Derivatives diff (function) % Higher Order Derivatives diff (function , n) n-difference order
First Order Derivatives compute the derivative of the function f(t) = 3 t 2 + 2 t-2 % First, define the symbolic variables in the equation >> syms t % Second, defining the function >> f = 3*t^2 + 2*t^(-2); % Finally enter the differentiation command >> diff(f) >> ans = 6*t - 4/t^3
Higher Order Derivatives Determine the acceleration of a free fall object from rest, and the formula for the distance: y=(g/k)*t-(g/kˆ2)*[1 -expˆ(- k t)]. % define the symbolic variables. >> syms g k t % Write the formula for y = f(t) >> y = (g/k)*t-(g/kˆ2)*(1 -exp(-k * t)); % Determine the velocity >> v = diff(y, t) % Determine the acceleration >> a = diff(v, t)
Previous example Determine the acceleration of a free fall object from rest, and the formula for the distance: y=(g/k)*t-(g/kˆ2)*[1 -expˆ(- k t)]. % define the symbolic variables. >> syms g k t % Write the formula for y = f(t) >> y = (g/k)*t-(g/kˆ2)*(1 -exp(-k * t)); % Determine the acceleration >> a = diff(y, t, 2)
Useful functions function diff(F) description differentiates F with respect to the variable determined by symvar(F, 1). diff(F, X) differentiates F with respect to the variable X. diff(F, n) computes the nth derivative of F with respect to the variable determined by symvar. diff(F, X, n) computes the nth derivative of F with respect to the variable X.
MATLAB Integration The MATLAB command for creating a line graph is int. General Form: Int(f) the indefinite integral or antiderivative of f. % Higher Order Derivatives int(f, v) uses the symbolic object v as the variable of integration
First Order Derivatives compute the derivative of the function f(t) = 3 t 2 + 2 t-2 % First, define the symbolic variables >> syms x n % Second, defining the function >> f = n^x; % Finally enter the integration command >> int(f) >> ans = n^x/log(n)
Definite integration General Form: function Form int(f, a, b) int(f, v, a, b)
Simple Examples
Test Your Understanding
- Slides: 11