0% found this document useful (0 votes)
11 views2 pages

Labsheet 4 (Derivatives)

This lab sheet provides instructions for finding derivatives using MATLAB's Symbolic Math Toolbox. It includes essential commands like 'syms' for defining symbolic variables and 'diff' for computing derivatives, along with examples and exercises to practice. The document emphasizes creating scripts or functions to solve derivative problems while documenting each step.

Uploaded by

ADHI KESAVAN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views2 pages

Labsheet 4 (Derivatives)

This lab sheet provides instructions for finding derivatives using MATLAB's Symbolic Math Toolbox. It includes essential commands like 'syms' for defining symbolic variables and 'diff' for computing derivatives, along with examples and exercises to practice. The document emphasizes creating scripts or functions to solve derivative problems while documenting each step.

Uploaded by

ADHI KESAVAN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Lab Sheet: Finding Derivatives in MATLAB

Objective
This lab will guide you through finding derivatives of functions using MATLAB’s
Symbolic Math Toolbox. You’ll solve examples and complete exercises to reinforce
your understanding of derivatives.
MATLAB Commands to Know
 syms — Define symbolic variables.
 diff — Compute the derivative of a function.
Getting Started
1. Open MATLAB.
2. Ensure the Symbolic Math Toolbox is installed.
3. Use syms to declare symbolic variables for your functions.
1. Basic Syntax for Derivatives in MATLAB
To find the derivative of a function f(x) with respect to x:
syms x
f = <your function>;
df = diff(f, x);
To find higher-order derivatives, specify the order:
d2f = diff(f, x, 2); % Second derivative of f with respect to x
2. Examples
Example 1: First Derivative

syms x
f = x^3 + 5*x^2 - 2*x + 7;
df = diff(f, x);
disp(df);

Example 2: Second Derivative


syms x
f = exp(2*x) * sin(x);
d2f = diff(f, x, 2);
disp(d2f);
Expected Output: The second derivative is a more complex expression involving
exponential and trigonometric terms.
3. Exercises
Solve the following derivative problems using MATLAB. For each exercise, create a
script or function to calculate the derivative, and include comments to explain each
step.

You might also like