DAYANANDA SAGAR ACADEMY OF TECHNOLOGY & MANAGEMENT
(Autonomous Under VTU)
Opp. Art of Living, Udayapura, Kanakapura Road, Bangalore - 560082
(Affiliated to Visvesvaraya Technological University, Belagavi and Approved by AICTE, New Delhi)
CE, CSE, ECE, EEE, ISE and ME are Accredited by NBA, New Delhi
NAAC Accredited with A+ Grade
Engineering Mathematics – 1 (BMATS/E101)
MATLAB Programs
SEMISTER: 1st Sem
Topic: MATLAB Programs
Submitted by
Student Name Branch Roll Number
Raksha P CSE 51
Rakshith CSE 52
Ranvitha CSE 53
Rashi CSE 54
Rida CSE 55
Course Handling Faculty
Dr. Fathimunnisa
Assistant Professor
Department of Mathematics
Academic Year 2025-26
1
TABLE OF CONTENTS
1. Program 1 – Total Derivative using MATLAB ................................................................... 3
1.1 Mind Map / Flowchart ...............................................................................................3
1.2 MATLAB Code ...............................................................................................................3
1.3 Output .............................................................................................................................4
2. Program 2 – Solution of RLC Circuit Differential Equation ..........................................5
2.2 Mind Map / Flowchart ...............................................................................................5
2.3 MATLAB Code ...............................................................................................................5
2.4 Output .............................................................................................................................6
3. Program 3 – Numerical Solution of Wave Equation ........................................................7
3.2 Mind Map / Flowchart ...............................................................................................7
3.3 MATLAB Code ...............................................................................................................7
3.4 Output .............................................................................................................................8
4. Conclusion .....................................................................................................................................9
2
Program 1: Total Derivative using MATLAB
Using MATLAB, compute the total derivative of the function:
f (x, y) = x + y²
when: x = t², y = sin(t)
1.1 Mindmap
1.2 MATLAB Code:
syms x y t f(x,y) x_t(t) y_t(t)
% Define the function f(x,y)
f = x + y^2;
% Define x(t) and y(t)
x_t = t^2;
y_t = sin(t);
% Compute partial derivatives
3
df_dx = diff(f, x);
df_dy = diff(f, y);
% Compute derivatives of x(t) and y(t)
dx_dt = diff(x_t, t);
dy_dt = diff(y_t, t);
% Apply total derivative formula
total_derivative = df_dx * dx_dt + df_dy * dy_dt;
% Substitute x(t) and y(t)
total_derivative = subs(total_derivative, [x, y], [x_t, y_t]);
% Simplify result
total_derivative = simplify(total_derivative);
% Display output
disp('Total derivative of f with respect to t is:')
disp(total_derivative)
1.3 Output:
Total derivative of f with respect to t is:
2*t + sin(2*t)
4
Program 2: RLC Circuit Differential Equation Solution
Using MATLAB, solve the differential equation governing an RLC circuit:
d²q/dt² + (1/LC) q = 0
Given: L=1, C = 0.25, H = 0.25
2.1 Mindmap
2.2 MATLAB Code:
% Define the given parameters
L = 1; % Inductance
C = 0.25; % Capacitance
% Define differential equation
syms q(t)
ode = diff(q, t, 2) + (1/(L*C))*q == 0;
% Solve the equation
5
solution = dsolve(ode);
% Display solution
disp('The general solution is:')
disp(solution)
2.3 Output:
The general solution is:
C1*cos(2*t) - C2*sin(2*t)
6
Program 3: Numerical Solution of Wave Equation
Using MATLAB, obtain the numerical solution of the wave equation with the following initial conditions:
u(x, 0) = sin(πx),
∂u/∂t (x, 0) = 0
3.1 Mindmap
3.2 MATLAB Code:
% Numerical values of wave equation solution
% Take input from user
xmax = input('Enter maximum x value: ');
tmax = input('Enter maximum t value: ');
n = input('Enter number of divisions: ');
% Define space and time
x = linspace(0, xmax, n);
t = linspace(0, tmax, n);
% Create space-time grid
[X, T] = meshgrid(x, t);
7
% Wave equation solution
u = sin(pi*X) .* cos(pi*T);
% Display output
disp('Solution matrix u(x,t) = ');
disp(u);
3.3 Output:
Enter maximum x value: 1
Enter maximum t value: 1
Enter number of divisions: 3
Solution matrix u(x,t) =
0 1.0000 0.0000
0 0.0000 0.0000
0 -1.0000 -0.0000
8
Conclusion
• This assignment successfully demonstrated the practical application of MATLAB in solving
symbolic, analytical, and numerical problems commonly encountered in mathematics and
engineering.
• In the first program, the concept of total differentiation for multivariable functions was
implemented using MATLAB’s symbolic computation capabilities. This helped in understanding the
use of partial derivatives and the chain rule in evaluating the rate of change of a function with
respect to an independent variable.
• The second program focused on solving a second-order differential equation representing an RLC
electrical circuit. MATLAB’s symbolic solver efficiently provided the general solution, highlighting
its effectiveness in handling complex differential equations that arise in real-world engineering
systems.
• The third program illustrated the numerical solution of the wave equation using given initial
conditions. By employing matrix operations and grid-based computation, MATLAB proved to be a
powerful tool for visualizing and analyzing dynamic physical phenomena through numerical
methods.
• Overall, these experiments enhanced our understanding of mathematical modelling, differential
equations, and numerical techniques while strengthening our proficiency in MATLAB
programming. The assignment clearly demonstrates that MATLAB is an indispensable
computational tool for engineers and scientists due to its accuracy, flexibility, and ability to handle
both symbolic and numerical computations efficiently.