Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
12 views5 pages

1 - Introduction To Matlab

The document is a lab manual for an introductory MATLAB experiment, outlining objectives, theory, and basic commands. It provides instructions for using the MATLAB interface, writing scripts, and performing various numerical analysis tasks. The manual includes a series of tasks for students to complete using MATLAB, focusing on matrix operations and basic programming concepts.

Uploaded by

Mujahid Irfan
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)
12 views5 pages

1 - Introduction To Matlab

The document is a lab manual for an introductory MATLAB experiment, outlining objectives, theory, and basic commands. It provides instructions for using the MATLAB interface, writing scripts, and performing various numerical analysis tasks. The manual includes a series of tasks for students to complete using MATLAB, focusing on matrix operations and basic programming concepts.

Uploaded by

Mujahid Irfan
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
You are on page 1/ 5

Computer Science & Numerical Analysis Lab Manual

Experiment 1

Introduction to MATLAB

Objective:

 To understand the basics of MATLAB


 To perform basic functions in MATLAB required for numerical analysis

Theory:
MATLAB stands for MATrix LABoratory. It was originally written by Dr. Cleve Moler at the University of
New Mexico in the 1970s and was commercialized by MathWorks in the 1980s. It is a numerical package that
allows complex equations to be solved efficiently and subsequently generate tabular or graphical output. Some
of the features of MATLAB are as follows:

 Matrix based computing environment


 Case-sensitive
 Can handle complex numbers
 High-Level programming language
 Visualization of data can be carried out using advanced graphics ( 2D & 3D)

MATLAB Interface:
To open MATLAB, follow the sequence as given:
 Start menu Select Programs Select MATLAB

Designed & Prepared by Engr. Syed Ahtisham Mehmood Shah


Computer Science & Numerical Analysis Lab Manual
Experiment 1

Command Window:
Command window is used to enter commands & data, for making calculations and printing results. A script can
also be written and executed in the command window but writing a script directly into the command window is
discouraged because it will not be saved, and if an error occurs, the entire script must be retyped.

Current Folder:

This window lists all the files in the Current Folder. By double clicking on a file in this window, the file will
open within MATLAB.

Work Space:

It enlists all the variables used in a running a script file.

Writing Scripts:

For writing scripts, click on “New Script” in the upper left corner. The interface will look as shown:

Now write a program which adds two numbers as shown:

Designed & Prepared by Engr. Syed Ahtisham Mehmood Shah


Computer Science & Numerical Analysis Lab Manual
Experiment 1

To run this program, go to “Editor” in the upper left corner and select “Run”. Then save the file in a folder and
observe the output in command window as shown.

You can observe as we have added 3 and 5 to get 8. The variables used in our program are listed in work space.
Designed & Prepared by Engr. Syed Ahtisham Mehmood Shah
Computer Science & Numerical Analysis Lab Manual
Experiment 1

Basic Commands:

Some of the basic commands used in MATLAB scripts are given as follows:

Sr. No Command Description


1 clc Clears the command window
2 Clear all Clears all work space
3 Close all Closes all the figures

Task 1:

Write the following expressions in MATLAB:



Task 2:

Make a row vector in MATLAB consisting of 4 elements and then call each element in command window.

Task 3:

Make a column vector in MATLAB consisting of 4 elements and then call each element in command window.

Task 4:

Make a 3×3 square matrix in MATLAB and then call each element in command window.

Task 5:

Concatenate two matrices in MATLAB.

Task 6:

Construct the following matrices in MATLAB:

 Matrix containing only zeros


 Matrix containing only ones
 Identity matrix

Designed & Prepared by Engr. Syed Ahtisham Mehmood Shah


Computer Science & Numerical Analysis Lab Manual
Experiment 1

Task 7:

Take transpose of a matrix in MATLAB.

Task 8:

Produce an array containing values between -10 and 10.

Task 9:

Evaluate the expressions in task 1 on the values obtained in task 8 such that the answers should be in decimal.

Task 10:

Produce an array of numbers from 1 to 10 using for loop.

Task 11:

Apply if else condition to check whether the numbers 12 and 13 are even or odd.

Task 12:

Apply if else conditions to check whether the answers in task 9 are even or odd.

Conclusion:

Designed & Prepared by Engr. Syed Ahtisham Mehmood Shah

You might also like