0% found this document useful (0 votes)
20 views11 pages

MATLAB Programming Laboratory Manual

The MATLAB Programming Laboratory Manual outlines a series of experiments designed for B.Tech students in their third year, focusing on MATLAB's tools, scripting, and Simulink applications. Each experiment includes aims, theory, procedures, and expected results, covering topics such as matrix operations, plotting, control flow, and PID controller implementation. Successful completion of the course enables students to perform mathematical operations, simulate models, and utilize MATLAB's features effectively.

Uploaded by

Yaquin's Lab
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views11 pages

MATLAB Programming Laboratory Manual

The MATLAB Programming Laboratory Manual outlines a series of experiments designed for B.Tech students in their third year, focusing on MATLAB's tools, scripting, and Simulink applications. Each experiment includes aims, theory, procedures, and expected results, covering topics such as matrix operations, plotting, control flow, and PID controller implementation. Successful completion of the course enables students to perform mathematical operations, simulate models, and utilize MATLAB's features effectively.

Uploaded by

Yaquin's Lab
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

MATLAB PROGRAMMING

LABORATORY MANUAL

[Link]
(III YEAR – V SEM)
(2025-26)

PREPARED BY:
MR. BENJAMIN DANGMEI
ASSISTANT PROFESSOR

DEPARTMENT OF ELECTRICAL ENGINEERING


PRATAP INSTITUTE OF TECHNOLOGY & SCIENCE, SIKAR
List of Experiments
S. No. List of Experiments Hours
1. Introduction to MATLAB, its various tools and files. 3
2. Create matrices, vectors, array, multi-dimensional matrices and 3
perform their basic operations through script file in MATLAB (one
example of each).
3. Scripts and functions; Global Variables; Open, saving and loading 3
data; Debugging of scripts.
4. Create script files demonstrating the plot and sub-plot of simple 3
graphs and their editing through figure editor tools. Perform label,
title, legend, axis, zoom-in, zoom-out operations.
5. Demonstrate Loops, Advanced data objects, Break-point and 3
Structures by writing script files (through tutorial sheets).
6. Demonstrate If-else, Branches and Control flow through writing 3
example script files (through tutorial sheets).
7. Applications: linear algebra, curve fitting, interpolation, numerical 3
integration, ordinary differential equation (cover through tutorial
sheets).
8. Simulink: Basics of Simulink, Problems based on Simulink. Draw and 3
simulate a Simulink model of a transfer function and get its step and
ramp responses.
9. Implement a PID controller and perform its tuning through PID 3
controller tuning toolbox.

COURSE OUTCOMES:
Upon successful completion of the course, the students will be able to:
• CO-1: Write scripts and functions in MATLAB to perform mathematical
operations on matrices, arrays and constants.
• CO-2: Draw the responses of any kind of system using plot features of MATLAB.
• CO-3: Demonstrate the loop, if-else, control flow, break-point operations.
• CO-4: Simulate a model in Simulink to get the desired response.
EXPERIMENT 1
Introduction to MATLAB, Its Tools and Files

Aim:
To study MATLAB environment, tools, command window, workspace, editor, and file
handling.

Theory:
MATLAB is a high-level programming environment used for numerical computation,
visualization, and algorithm development. Its interface includes command window,
workspace, editor, figure window, and various toolboxes. MATLAB files include script files
(.m), function files, MAT files, and workspace files.

Procedure:
1. Open MATLAB and observe the command window, workspace, editor, and file
browser.
2. Create a new script and write simple arithmetic operations.
3. Save the script using .m extension.
4. Run the script and observe results in the command window.

Result:
Basic tools and file handling features of MATLAB were successfully explored.
EXPERIMENT 2
Create Matrices, Vectors, Arrays Through Script File

Aim:
To create matrices, vectors, arrays, and multidimensional matrices using MATLAB
script.

Theory:
MATLAB is built for matrix operations. It supports row/column vectors, 2D matrices,
and higher-dimensional arrays. MATLAB uses built-in functions like zeros(), ones(), rand(),
eye() for array creation.

Procedure:
1. Open a new script in MATLAB.
2. Write commands to create row vectors, column vectors, and matrices.
3. Create a 3D matrix using the reshape() function.
4. Save and run the script.

Result:
Vectors, matrices, and multidimensional arrays were created successfully in
MATLAB.
EXPERIMENT 3
Scripts, Functions, Global Variables, File I/O

Aim:
To write MATLAB scripts and functions, use global variables, and perform file
read/write operations.

Theory:
Scripts run sequential commands, while functions return output arguments. Global
variables allow shared data between functions. MATLAB supports file handling using fopen,
fprintf, fscanf, and load/save commands.

Procedure:
1. Create a script file and define variables.
2. Write a function in a separate .m file.
3. Use global keyword to share variables.
4. Write data to a text file and read it back.

Result:
Scripts, functions, and file-handling operations were implemented successfully.
EXPERIMENT 4
Plot and Sub-Plot of Graphs; Editing Using Figure Tools

Aim:
To plot single and multiple graphs, add labels, legends, grid, and customize using
figure editor tools.

Theory:
MATLAB provides plot(), subplot(), title(), xlabel(), ylabel(), legend(), grid functions.
The figure editor allows zooming, panning, and manual changes to plots.

Procedure:
1. Create a script containing two different mathematical functions.
2. Plot them using plot() and subplot().
3. Add labels, grid, and legend.
4. Use figure editor to zoom, change colors, and save figure.

Result:
Required plots were generated and formatted using MATLAB plotting tools.
EXPERIMENT 5
Loops, Data Objects, Break-Point and Debugging

Aim:
To demonstrate loops, arrays, break-points, and debugging features in MATLAB.

Theory:
MATLAB supports for, while loops, if-else conditions, and break statements.
Debugging tools include breakpoints, step-in, step-out, and variable inspection.

Procedure:
1. Create a program using for and while loops.
2. Insert break-points in MATLAB editor.
3. Run the script and use debugging tools to execute step by step.
4. Observe variable changes in workspace.

Result:
Looping, break-points, and debugging techniques were successfully demonstrated.
EXPERIMENT 6
If-Else, Branching, Control Flow

Aim:
To implement branching and conditional statements in MATLAB using example
scripts.

Theory:
Conditional statements (if, elseif, else, switch) allow decision-based program
execution. Control flow supports structured programming in MATLAB.

Procedure:
1. Create a script containing if-else and switch statements.
2. Run the program with different inputs.
3. Observe output changes for each condition.

Result:
Control flow and conditional execution were implemented successfully.
EXPERIMENT 7
Applications — Linear Algebra, Curve Fitting, Interpolation, Numerical Methods

Aim:
To perform linear algebra, curve fitting, interpolation, and numerical operations using
MATLAB.

Theory:
MATLAB provides built-in functions for matrix algebra (inv, det, eig), curve fitting
(polyfit, polyval), interpolation (interp1, spline), and numerical integration/differentiation.

Procedure:
1. Create matrices and perform linear algebra operations.
2. Fit a polynomial curve to sample data.
3. Interpolate missing values.
4. Solve a differential equation using numerical methods.

Result:
MATLAB successfully executed linear algebra, curve fitting, interpolation, and
numerical operations.
EXPERIMENT 8
Simulink — Basics and Transfer Function Simulation

Aim:
To build and simulate a Simulink model of a transfer function and obtain step and
ramp responses.

Theory:
Simulink is a block-diagram simulation tool integrated with MATLAB. Transfer
functions are modelled using blocks like gain, sum, transfer function, and scope.

Procedure:
1. Open Simulink and create a new model.
2. Add transfer function and input blocks.
3. Connect blocks and run the simulation.
4. Observe step and ramp responses.

Result:
Step and ramp responses of the transfer function were obtained successfully.
EXPERIMENT 9
PID Controller Implementation and Tuning

Aim:
To implement a PID controller and perform tuning using MATLAB PID toolbox.

Theory:
A PID controller uses proportional, integral, and derivative control actions. MATLAB
provides automatic tuning through the PID tuner.

Procedure:
1. Open Simulink and insert PID controller block.
2. Connect it to a plant model.
3. Open PID tuner and auto-tune parameters.
4. Simulate the system and study output.

Result:
PID controller was implemented and tuned successfully.

You might also like