0% found this document useful (0 votes)
26 views

Lab 1

This document provides an introduction and overview of MATLAB for a Civil Engineering course. It discusses starting a MATLAB session, the main components of the MATLAB environment like the command window and workspace. It also summarizes MATLAB's capabilities for numerical computation, data analysis, visualization and programming. Basic MATLAB commands and symbols are defined. The document aims to familiarize students with the MATLAB software interface and functionality.

Uploaded by

Mian Blal
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

Lab 1

This document provides an introduction and overview of MATLAB for a Civil Engineering course. It discusses starting a MATLAB session, the main components of the MATLAB environment like the command window and workspace. It also summarizes MATLAB's capabilities for numerical computation, data analysis, visualization and programming. Basic MATLAB commands and symbols are defined. The document aims to familiarize students with the MATLAB software interface and functionality.

Uploaded by

Mian Blal
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

SESSION: 2018-2022 CIVIL ENGINEERING DEPARTMENT

LAB#1:
INTRODUCTION TO MATLAB
(BASIC CONCEPTS)

Learning Objectives:
• Starting and Ending a MATLAB session.
• Learn about the major components of MATLAB environment.
• Learn to use Help Browser and help Command.
• Know about different types of files used in MATLAB.
• Know the various platforms where MATLAB can be used.
• Some other useful general commands.

Introduction:
MATLAB stands for MATRIX LABORATORY. A special purpose computer program optimized to perform
Engineering and Scientific calculations or it is a Technical programming language. It is started with simple matrix
manipulation and grown with the capability of solving any technical problem. It is a proprietary programming
language developed by Math-works. It provides a very extensive library of pre-defined functions to make technical
programming task easier and more efficient. It is superior on other languages like C, C++, FORTRAN.

MATLAB Capabilities:
 Numerical computation
 Data Access
 Data Analysis and Visualization
 Programming and Algorithm development
 Application development and deployment

Data Analysis and Visualization:


 Preprocessing
 Fast and accurate analysis (Correlation, Fourier analysis and Filtering, Basic Statistics and Curve fitting)
 Built-in functions for Matrix operations (Cholesky factorization, LU Factorization)
 Special Math functions (Airy function, Bessel function, Beta and Gamma function, Laplace transforms,
Fourier transforms, Interpolation, Polynomials and ODE solvers)
 Built-in Graphics for Engineering and Science (2D and 3D Plots, Volume Visualization)

MATLAB MANUAL 1
SESSION: 2018-2022 CIVIL ENGINEERING DEPARTMENT

MATLAB Environment:

The major components of MATLAB environment are as follows:

 Command window
 Command history
 Workspace
 Current folder
 Figure window
 Edit window

1. Command Window:
Whenever MATLAB is involved the main window called command window is activated. The command window
displays the command prompt “>>” and a cursor where commands are entered and are executed instantaneously on
pressing the “enter” key of the keyboard. Commands can be run by typing them in the command window.

2. Command History Window:


It consists of a list of all the commands that are entered at the command window. It consists of commands of
previous session also. These commands remain in the list untile they are deleted. Any command may be executed
by selecting and double clicking it with mouse. A program file may be created by selecting a set of commands and
right clicking the mouse. On right clicking the mouse, pop-up menu is displayed. A program file containing the
selected commands can be created by choosing “Create M.file” option from menu.
Similarly, commands may be deleted by selecting the command and right clicking the mouse and selecting “Delete
selection” from pop-up menu.

3. Workspace:

MATLAB MANUAL 2
SESSION: 2018-2022 CIVIL ENGINEERING DEPARTMENT

A workspace is a collection of all the variables that have been generated so far in the current MATLAB session
and shows their data type and size. The workspace information can also be obtained by typing command at the
command prompt. The “who” and “whos” command will generate list of variables currently in the workspace.
Workspace stores generated variables temporarily. The workspace will be cleared when we closed the MATLAB.
All the commands executed from command window and all the script files executed from the command window
share common workspace, so they can share all the variables. Using these variables, a number of operations can be
done such as plotting by selecting a variable and right clicking the mouse and selecting the desired option from
pop-up menu.

4. Current Folder:
It contained all executed programs and save MATLAB files. In the current folder window, all the files and folder
present in the current directory will be listed. To run any file it must either be in the current directory or on the
search path. A quick way to view or change the current directory or its content is by using the current directory
field in MATLAB toolbar. For this click on “DESKTOP” on the menu bar and check the boxes to show window.

5. Edit Window:
An edit window is used to create a new program file or to modify existing files. In the window, programs can be
written, edited and save. The programs written using a MATALB editor are automatically assigned an extension
“.m” by the editor and are known as M. files. A new M. file can be created by selecting an appropriate option from
the desktop “file” menu. An existing M. file can be opened by selecting “file” from menu bar and then click
“Open” from desktop menu. The window editor is open automatically when a new M. file is created or and
existing M. file is opened.

6. Figure Window:
A figure window is a separate window with default white background and is used to display MATLAB graphics.
The result of all the graphics command executed or displayed in the figure window. There can be any number of
figure windows depending upon the system memory. To open figure window write “figure” in command window
and press enter key. A figure window is displayed.

MATLAB Symbols with their Operations:

Symbols Operations
+ Used for addition e.g. >>2+3
- Used for subtraction e.g. >>3-2
* Used for multiplication e.g. >>2*x
/ Used for division e.g. >> 2/5
^ Used for exponentiation e.g. >>2^4 →24
sqrt To find square root e.g. sqrt(4)
% Used to write comments or any statements that we do not want to execute.
pi Used for π (3.141592……)
; To terminate a line and suppress the result to display on command window
MATLAB MANUAL 3
SESSION: 2018-2022 CIVIL ENGINEERING DEPARTMENT

e.g. >>x=2;
It will not be executed
Used to define a range
e.g.
we want to write counting from 1 to 100 with gap 1, then >>1:1:100
It will display all numbers from 1 to 100.
: Generally,
Initial point : desired gap : final point
>>2:2:20 %TABLE OF 2
It will display.
2 4 6 8 …...20
It is typed in the beginning of a line in edit window. It create cell (highlighted
%%
rectangle) which can be executed separately / individually by using icon.

Some useful MATLAB Commands:


Command
Description
s
clc To clear screen of command window
clf To clear figure window
who List the variables currently in the workspace
whos Same as “who” command but gives more information such as type and size
what Display all saved file on command window
clear To clear workspace
clear all To clear variables in workspace
plot To plot a graph
fprintf To print the output on the screen / command window
quit/exit To close the MATLAB session

Docking and Undocking:


Docking means attaching the window to MATLAB environment. This is done by clicking the icon on the top
right corner of every window. Undocking means detaching the window from MATLAB environment.

MATLAB MANUAL 4

You might also like