Practical 1: Part A
Introduction To Matlab Software and Work Environment
1.1 Introduction
The primarily objective is to help you learn quickly the first steps. The emphasis here is “learning by
doing”. Therefore, the best way to learn is by trying it yourself. Working through the examples will
give you a feel for the way that MATLAB operates. In this introduction we will describe how
MATLAB handles simple numerical expressions and mathematical formulas.
The name MATLAB stands for Matrix Laboratory. MATLAB was written originally to provide easy
access to matrix software developed by the LINPACK (linear system package) and EISPACK (Eigen
system package) projects.
The basic building block in MATLAB is the matrix. The fundamental data type is the array.
Vectors, scalars, real and complex matrices are all automatically handled as special cases of basic
arrays. The built-in functions are optimized for vector operations. Thus, vectorized commands or
codes run much faster in MATLAB (vectorization is a way of computing in which an operation is
performed simultaneously on a list of numbers rather than sequentially on each member of the list).
A nice thing to realize is that MATLAB is primarily a numerical computation package,
although with the 'Symbolic' Toolbox it can do also symbolic algebra. Mathematica, Maple, and
Macsyma are primarily symbolic algebra packages. MATLAB's ease of use is its best feature since
you can have more learning with less effort, while the computer algebra systems have a steeper
learning curve.
In mathematical computations, especially those that utilize vectors and matrices, MATLAB is better in
terms of ease of use, availability of built-in functions, ease of programming, and speed. MATLAB's
popularity today has forced such packages as Macsyma and Mathematica to provide extensions for
files in MATLAB's format.
There are numerous prepared commands for 2D and 3D graphics as well as for animation. The
user is not limited to the built-in functions; he can write his own functions in MATLAB language.
Once written, these functions work just like the internal functions. MATLAB's language is designed to
be easy to learn and use.
The many built-in functions provide excellent tools for linear algebra, signal processing, data
analysis, optimization, solution of ordinary differential equations (ODEs), and many other types of
scientific operations.
EE-218 Computer Programming for Electrical Engineering (N.M.E.E: BE03000191) 1
There are also several optional 'toolboxes' available which are collections of functions written for
special applications such as 'Image Processing', 'Statistics', 'Neural Networks', etc.
The software package has been commercially available since 1984 and is now considered as a standard
tool at most universities and industries worldwide.
1.2 Starting and Quitting MATLAB
1.2.1 Starting MATLAB
On a Microsoft Windows platform, to start MATLAB, double-click the MATLAB shortcut icon on
your Windows desktop. On Linux, to start MATLAB, type Matlab at the operating system prompt.
After starting MATLAB, the MATLAB desktop opens – see “MATLAB Desktop”.
You can change the directory in which MATLAB starts, define startup options including running a
script upon startup, and reduce startup time in some situations.
1.2.2 Quitting MATLAB
To end your MATLAB session, select Exit MATLAB from the File menu in the desktop, or type quit
in the Command Window. To execute specified functions each time MATLAB quits, such as saving
the workspace, you can create and run a finish.m script.
1.3 MATLAB Desktop
When you start MATLAB, the MATLAB desktop appears, containing tools (graphical user interfaces)
for managing files, variables, and applications associated with MATLAB.
The first time MATLAB starts, the desktop appears as shown in the following illustration, although
your Launch Pad may contain different entries.
1.4 Desktop Tools
This section provides an introduction to MATLAB’s desktop tools. You can also use MATLAB
functions to perform most of the features found in the desktop tools. The tools are:
• Command Window”.
• Command History.
• Launch Pad
• Help Browser.
• Current Directory Browser.
• Workspace Browser.
• Array Editor.
EE-218 Computer Programming for Electrical Engineering (N.M.E.E: BE03000191) 2
• Editor/Debugger.
1.4.1 Command Window
Use the Command Window to enter variables and run functions and M-files.
Figure 1: MATLAB Work Environment.
You can change the way your desktop looks by opening, closing, moving, and resizing the tools in it.
You can also move tools outside of the desktop or return them back inside the desktop (docking). All
the desktop tools provide common features such as context menus and keyboard shortcuts. You can
specify certain characteristics for the desktop tools by selecting Preferences from the File menu. For
example, you can specify the font characteristics for Command Window text. For more information,
click the Help button in the Preferences dialog box.
EE-218 Computer Programming for Electrical Engineering (N.M.E.E: BE03000191) 3
Figure 2: Command Window.
Figure 3: Customization
1.4.2 Command History
EE-218 Computer Programming for Electrical Engineering (N.M.E.E: BE03000191) 4
Figure 4: Command History
Lines you enter in the Command Window are logged in the Command History window. In the
Command History, you can view previously used functions, and copy and execute selected lines.To
save the input and output from a MATLAB session to a file, use the diary function.
1.4.3 Running External Programs
You can run external programs from the MATLAB Command Window. The exclamation point
character! is a shell escape and indicates that the rest of the input line is a command to the operating
system. This is useful for invoking Timestamp marks the start of each session. Select one or more lines
and right-click to copy, evaluate, or create an M-file from the selection. Utilities or running other
programs without quitting MATLAB. On Linux, for example, !emacsmagik.m invokes an editor called
emacs for a file named magik.m. When you quit the external program, the operating system returns
control to MATLAB.
1.4.4 Launch Pad
EE-218 Computer Programming for Electrical Engineering (N.M.E.E: BE03000191) 5
MATLAB’s Launch Pad provides easy access to tools, demos, and documentation
Figure 5: Launch Pad
1.4.5 Help Browser
Use the Help browser to search and view documentation for all MathWorks products. The Help
browser is a Web browser integrated into the MATLAB desktop that displays HTML documents.
1.4.6 Current Directory Browser
MATLAB file operations use the current directory and the search path as reference points. Any file
you want to run must either be in the current directory or on the search path. A quick way to view or
change the current directory is by using the Current Directory field in the desktop toolbar as shown
below.
EE-218 Computer Programming for Electrical Engineering (N.M.E.E: BE03000191) 6
Figure 6: Help Browser
To open the Help browser, click the help button in the toolbar, or type helpbrowser in the
Figure 7: Current Directory Browser.
To search for, view, open, and make changes to MATLAB-related directories and files, use the
MATLAB Current Directory browser. Alternatively, you can use the functions dir, cd, and delete.
EE-218 Computer Programming for Electrical Engineering (N.M.E.E: BE03000191) 7
Search Path
To determine how to execute functions you call, MATLAB uses a search path to find M-files
and other MATLAB-related files, which are organized in directories on your file system. Any file you
want to run in MATLAB must reside in the current directory or in a directory that is on the search
path. By default, the files supplied with MATLAB and MathWorks toolboxes are included in the
search path.
To see which directories are on the search path or to change the search path, select Set Path
from the File menu in the desktop, and use the Set Path dialog box. Alternatively, you can use the path
function to view the search path, addpath to add directories to the path, and rmpath to remove
directories from the path.
1.4.7 Workspace Browser
The MATLAB workspace consists of the set of variables (named arrays) built up during a MATLAB
session and stored in memory. You add variables to the workspace by using functions, running M-
files, and loading saved workspaces.
To view the workspace and information about each variable, use the Workspace browser, or use the
functions who and whos.
To delete variables from the workspace, select the variable and select Delete from the Edit menu.
Alternatively, use the clear function.
The workspace is not maintained after you end the MATLAB session. To save the workspace to a file
that can be read during a later MATLAB session, select Save Workspace As from the File menu, or
use the save function. This saves the workspace to a binary file called a MAT-file, which has a .mat
extension. There are options for saving to different formats. To read in a MAT-file, select Import
Data from the File menu, or use the load function.
1.4.8 Array Editor
Double-click on a variable in the Workspace browser to see it in the Array Editor. Use the Array
Editor to view and edit a visual representation of one- or two-dimensional numeric arrays, strings, and
cell arrays of strings that are in the workspace.
EE-218 Computer Programming for Electrical Engineering (N.M.E.E: BE03000191) 8
Figure 8: Workspace & Array Editor.
1.5 Getting started
Now, we are interested in doing some simple calculations. We will assume that you have sufficient
understanding of your computer under which MATLAB is being run.
You are now faced with the MATLAB desktop on your computer, which contains the prompt (>>) in
the Command Window. Usually, there are 2 types of prompt:
>>for full version
EDU> for educational version
Note: To simplify the notation, we will use this prompt, >>, as a standard prompt sign, though our
MATLAB version is for educational purpose.
1.5.1 Using MATLAB as a calculator
As an example of a simple interactive calculation, just type the expression you want to evaluate. Let’s
start at the very beginning. For example, let’s suppose you want to calculate the expression, You type
it at the prompt command (>>) as follows,
EE-218 Computer Programming for Electrical Engineering (N.M.E.E: BE03000191) 9
>> 1+2*3
ans = 7
You will have noticed that if you do not specify an output variable, MATLAB uses a default variable
‘ans’, short for answer, to store the results of the current calculation. Note that the variable ‘ans’ is
created (or overwritten, if it is already existed). To avoid this, you may assign a value to a variable or
output argument name. For example,
>> x = 1+2*3
x=7
will result in x being given the value. This variable name can always be used to refer to the results of
the previous computations. Therefore, computing 4x will result in
>> 4*x
ans = 28.0000
Before we conclude this minimum session, Tables below gives the partial list of commonly used
MATLAB operators and special characters used to solve many engineering and science problems.
1.5.2 Creating MATLAB variables
MATLAB variables are created with an assignment statement. The syntax of variable assignment is
variable name = a value (or an expression)
For example,
>> x = expression
Where expression is a combination of numerical values, mathematical operators, variables, and
function calls. On other words, expression can involve:
• Manual entry
• Built-in functions
• User-defined functions
1.5.3 Overwriting variable
Once a variable has been created, it can be reassigned. In addition, if you do not wish to see the
intermediate results, you can suppress the numerical output by putting a semicolon (;) at the end of the
line. Then the sequence of commands looks like this:
>> t = 5;
EE-218 Computer Programming for Electrical Engineering (N.M.E.E: BE03000191) 10
>> t = t+1
t=6
1.5.4 Error messages
If we enter an expression incorrectly, MATLAB will return an error message. For example, in the
following, we left out the multiplication sign, *, in the following expression
>> x = 10;
>> 5x
??? 5x
Error: Unexpected MATLAB expression.
1.5.5 Making corrections
To make corrections, we can, of course retype the expressions. But if the expression is lengthy, we
make more mistakes by typing a second time. A previously typed command can be recalled with the
up-arrow key ↑. When the command is displayed at the command prompt, it can be modified if needed
and executed.
1.5.6 Controlling the hierarchy of operations or precedence
Let’s consider the previous arithmetic operation, but now we will include parentheses. For example,
will become
>> (1+2)*3
ans = 9
and, from previous example 20 >> 1+2*3
ans = 7
By adding parentheses, these two expressions give different results: 9 and 7. The order in which
MATLAB performs arithmetic operations is exactly that taught in high school algebra courses.
Exponentiations are done first, followed by multiplications and divisions, and finally by additions and
subtractions. However, the standard order of precedence of arithmetic operations can be changed by
inserting parentheses. For example, the result of is quite different than the similar expression with
parentheses. The results are 7 and 9 respectively. Parentheses can always be used to overrule priority,
and their use is recommended in some complex expressions to avoid ambiguity. Therefore, to make
the evaluation of expressions unambiguous, MATLAB has established a series of rules.
EE-218 Computer Programming for Electrical Engineering (N.M.E.E: BE03000191) 11
Hierarchy of arithmetic Mathematical operations
operations. Precedence
First The contents of all parentheses are evaluated first, starting from the
innermost parentheses and working outward.
Second All exponentials are evaluated, working from left to right
Third All multiplications and divisions are evaluated, working from left to right
Fourth All additions and subtractions are evaluated, starting from left to right
MATLAB arithmetic operators functioning hierarchy
1.6 Summary of Commands
1.6.1 Operators and special Characteristics
Character Description
+ Addition
- Subtraction
* Multiplication
/ Division
^ Power
: Colon, creates vectors with equally spaced elements
; Semi colon, ends row in array
, Comma, separates array subscripts
% Percent, specifies output format
= Assignment operator
() Parentheses, encloses elements of arrays and input arguments
[] Brackets, encloses matrix elements and output arguments
‘ Single quote, creates string, specifies matrix transpose
1.6.2 Array Operators
Character Description
.* Array Multiplication
./ Array (right) Division
.\ Array (left) Division
.^ Array power
1.6.3 Relation and logical Operators
Character Description
< Less than
≤ Less than or equal to
> Greater than
EE-218 Computer Programming for Electrical Engineering (N.M.E.E: BE03000191) 12
≥ Greater than or equal to
== Equal to
~= Not equal to
& Logical or element wise AND
| Logical or element wise OR
&& Short circuit AND
|| Short circuit OR
1.6.4 Mathematical Functions
Exponential and Logarithmic Functions
exp (x) Exponential, ex
log (x) Natural logarithm, ln(x)
log10 (x) Common (base 10) logarithm
sqrt (x) Square root
Trigonometric Functions
acos (x) Inverse cosine
asin (x) Inverse sine
atan (x) Inverse tangent
acot (x) Inverse cotangent
acosec (x) Inverse cosecant
asec (x) Inverse secant
cos (x) cosine
sin (x) sine
tan (x) tangent
cot (x) cotangent
cosec (x) cosecant
sec (x) secant
Complex Functions
abs (x) Absolute value
angle (x) Angle of a complex number x
conj (x) Complex conjugate of x
imag (x) Imaginary part of a complex number x
real (x) Real part of a complex number x
Random Number Functions
rand Generates uniformly distributed random numbers between 0 to 1
randn Generates uniformly distributed random numbers
EE-218 Computer Programming for Electrical Engineering (N.M.E.E: BE03000191) 13
1.6.5 Plotting commands
Basic x-y Plotting Commands
axis Sets axis limits
fplot Intelligent plotting of functions
grid Displays gridlines
plot Generates xy plot
print Prints plot and saves plot to a file
title Puts text at top of plot
xlabel Adds text label to x axis
ylabel Adds text label to y axis
EE-218 Computer Programming for Electrical Engineering (N.M.E.E: BE03000191) 14
Practical 1: Part B
Introduction to Matlab Basic Commands
Semicolon operator:
A=5
B=9
C=10;
D=20
A= 5
B= 9
D = 20
Colon operator/indexing
Z=1:12
Z= 1 2 3 4 5 6 7 8 9 10 11 12
Z=1:1:12
Z= 1 2 3 4 5 6 7 8 9 10 11 12
Z=1:2:12
Z= 1 3 5 7 9 11
Z=12:-1:0
Z = 12 11 10 9 8 7 6 5 4 3 2 1 0
Displaying format of numbers
format long
320/12
ans = 26.666666666666668
EE-218 Computer Programming for Electrical Engineering (N.M.E.E: BE03000191) 15
format short
320/12
ans = 26.6667
format short e
320/12
ans =2.6667e+001
format bank
320/12
ans =26.67
Addition of two numbers:
clc
clear all
a=5
b=6
c=a+b
ans:
a =5
b =6
c = 11
Subtraction of two numbers:
a=5
b=6
d=a-b
ans:
d =-1
Multiplication of two numbers:
a=5
b=6
EE-218 Computer Programming for Electrical Engineering (N.M.E.E: BE03000191) 16
e=a*b
ans:
e =30
Square Root:
A= 16;
A=sqrt(A)
B=sqrt (64)
D=nthroot(64,3)
A =4
B =8
D =4.0
Trigonometric Function:
Cosine terms:
clc
clear all
a=cos(pi/2)
b=cos(90)
c=cos(180)
d=cos(pi)
e=cos (30*pi/180)
f= cos (30)
g=cos (45*pi/180)
i=cosd(0)
j=sind(30)
k=asind(0.5)
Ans:
a =6.1232e-017
b = -0.4481
c = -0.5985
d = -1
e =0.8660
f =0.1543
g =0.7071
EE-218 Computer Programming for Electrical Engineering (N.M.E.E: BE03000191) 17
i =1
j =0.5000
k= 30
Division of two numbers:
clc
clearall
a=5
b=6
d=a/b
ans:
d =0.833
Basic logicaloperator :
Logical not operator:
x=[2 3 0 1 5]
y=[1 5 3 6 1]
logical NOT
a=not(x);
a=~x
output
a =0 0 1 0 0
a=~y
output
a=
0 0 0 0 0
logical AND
a=and(x, y)
a=(x&y)
output
EE-218 Computer Programming for Electrical Engineering (N.M.E.E: BE03000191) 18
a =1 1 0 1 1
logical OR
a=or(x, y)
a=(x|y)
output
a =1 1 1 1 1
a =1 1 1 1 1
logical ANY
z=[ 1 0 1 0 1]
p=[ 0 0 0 0 0 ]
a=any (z)
a=any (p)
output
a =1
a =0
logical ALL
z=[ 1 1 1 1 1]
p=[ 0 1 0 0 0 ]
a=all (z)
a=all (p)
output
a =1
a =0
Logical FIND
x=[2 3 0 1 5]
y=[1 5 3 6 1]
a=find (x==4)
a=find (3)
a=find(x>2 )
a=find (x==1)
EE-218 Computer Programming for Electrical Engineering (N.M.E.E: BE03000191) 19
x(find(x>2))=17
output
a =Empty matrix: 1-by-0
a =1
a =2 5
a =4
x =2 17 0 1 17
Basic matrix algebra :
Entering/Storing a matrix:
clc
clear all
A= [1 2 3 4; 4 5 6 7;7 8 9 1;3 4 6 7]
Ans:
A=1 2 3 4
4 5 6 7
7 8 9 1
3 4 6 7
For summation of matrix (column wise):
clc
clear all
x=[2 3 0 1 5]
A=[1 2 3 4;4 5 6 7;7 8 9 1;3 4 6 7];
Y=sum(x)
Y=sum(A)
Y=cumsum(x)
Y =11
Y=15 19 24 19
Y =2 5 5 6 11
Finding Absolute Values
EE-218 Computer Programming for Electrical Engineering (N.M.E.E: BE03000191) 20
A= 5
B=-11
C=5+3i
x=abs(A)
x=abs(B)
x=abs(C)
x =5
x =11
x =5.8310
Product of Matrix elements
A=[1 2 3 4;4 5 6 7;7 8 9 1;3 4 6 7];
Y=prod (A)
Z=prod(prod(A))
Y = 84 320 972 196
Z = 5.1210e+009
For transpose of matrix:
clc
clear all
A'
ans = 1 4 7 3
2 5 8 4
3 6 9 6
4 7 1 7
For diagonal of matrix:
clc
clearall
A=[1 2 3;4 5 6;7 2 3]
diag(A)
EE-218 Computer Programming for Electrical Engineering (N.M.E.E: BE03000191) 21
A =1 2 3
4 5 6
7 2 3
ans =1
5
3
For minimum element of column wise of matrix:
clc
clear all
A=[1 2 3;4 5 6;7 1 3]
X= min(A)
[element_value, place]=min(A)
X=min(min(A))
A =1 2 3
4 5 6
7 1 3
X =1 1 3
element_value =1 1 3
place =1 3 1
X=1
For maximum element of column wise of matrix:
clc
clear all
A=[1 2 3;4 5 6;7 2 3]
max(A)
A =1 2 3
4 5 6
7 2 3
ans =7 5 6
EE-218 Computer Programming for Electrical Engineering (N.M.E.E: BE03000191) 22
For average element of column wise matrix:
clc
clear all
A=[1 2 3;4 5 6;7 2 3]
mean(A)
Y=mean(mean(A))
A =1 2 3
4 5 6
7 2 3
ans = 4 3 4
Y =3.6667
For standard deviation of matrix:
clc
clearall
A=[1 2 3;4 5 6;7 2 3]
std (A)
A =1 2 3
4 5 6
7 2 3
ans =3.0000 1.7321 1.7321
Matrix with all zeros:
clc
clear all
x=zeros(5,5)
x =0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
EE-218 Computer Programming for Electrical Engineering (N.M.E.E: BE03000191) 23
Matrix with all ones:
clc
clear all
x=ones(5,5)
x=1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
To find uniformly distributed random matrixbetween [1 to 1]:
clc
clear all
m=rand(5,5)
m =0.8147 0.0975 0.1576 0.1419 0.6557
0.9058 0.2785 0.9706 0.4218 0.0357
0.1270 0.5469 0.9572 0.9157 0.8491
0.9134 0.9575 0.4854 0.7922 0.9340
0.6324 0.9649 0.8003 0.9595 0.6787
To find normally distributed random matrix between [-1 to 1]:
clc
clear all
m=randn(6,6)
Ans:
m =1.0347 -1.1471 -0.7549 0.3129 1.1093 1.5326
0.7269 -1.0689 1.3703 -0.8649 -0.8637 -0.7697
-0.3034 -0.8095 -1.7115 -0.0301 0.0774 0.3714
0.2939 -2.9443 -0.1022 -0.1649 -1.2141 -0.2256
-0.7873 1.4384 -0.2414 0.6277 -1.1135 1.1174
0.8884 0.3252 0.3192 1.0933 -0.0068 -1.0891
EE-218 Computer Programming for Electrical Engineering (N.M.E.E: BE03000191) 24
Converting the subscript to linear index and vice-versa.
A=[1 2 3;4 5 6;7 2 3]
X=sub2ind ([3,3], 3,3)
X =9
X=sub2ind ([3, 3,], 1, 3)
X =7
X=sub2ind([3,3,], 1,2)
X =4
Y=ind2sub ([3,3],3)
Y=3
To generate column element of matrix:
clc
clear all
M=[1:25]
N=[1:10]
O=[0:5:15]
P=[0:2:20]
Q=[1:2:20]
M =Columns 1 through 15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Columns 16 through 25
16 17 18 19 20 21 22 23 24 25
N=Columns 1 through 6
EE-218 Computer Programming for Electrical Engineering (N.M.E.E: BE03000191) 25
1 2 3 4 5 6
Columns 7 through 10
7 8 9 10
O= 1 6 11
P=Columns 1 through 6
0 2 4 6 8 10
Columns 7 through 11
12 14 16 18 20
Q=Columns 1 through 6
1 3 5 7 9 11
Columns 7 through 10
13 15 17 19
Pi operator:
clc
clear all
m=[0:pi/4:pi]
m=0 0.7854 1.5708 2.3562 3.1416
Matrix operation with two matrix
Matrix addition:
clc
clear all
a=[1 2 3;4 5 6;7 8 9]
b=[3 4 5;2 3 8;9 4 5]
c=a+b
a =1 2 3
4 5 6
7 8 9
b =3 4 5
2 3 8
EE-218 Computer Programming for Electrical Engineering (N.M.E.E: BE03000191) 26
9 4 5
Ans:
c =4 6 8
6 8 14
16 12 14
Matrix subtraction:
clc
clear all
c=a-b
Ans:
c =-2 -2 -2
2 2 -2
-2 4 4
Matrix multiplication:
clc
clear all
c=a*b
ans:
c =34 22 36
76 55 90
118 88 144
Matrix division:
clc
clear all
c=a/b
ans:
c =0.4902 0.1176 -0.0784
1.2549 -0.0588 0.0392
2.0196 -0.2353 0.1569
Accessing a matrix/Array element:
EE-218 Computer Programming for Electrical Engineering (N.M.E.E: BE03000191) 27
b=[3 4 5;2 3 8;9 4 5];
y=b(2,2)
b(1,1)=10
y =3
b =10 4 5
2 3 8
9 4 5
Display row element of matrix:
clc
clear all
a= [1 2 3; 4 5 6; 7 8 9]
A (2, :)
a =1 2 3
4 5 6
7 8 9
Ans =4 5 6
A =1 2 3 4
5 6 7 8
1 3 2 4
5 7 6 8
>> A (4, 1:3)
ans =5 7 6
Display column element of matrix:
clc
clear all
EE-218 Computer Programming for Electrical Engineering (N.M.E.E: BE03000191) 28
a=[1 2 3;4 5 6;7 8 9]
a(:,2)
a =1 2 3
4 5 6
7 8 9
ans =2
5
8
Identity matrix:
clc
clear all
a=eye(3,3)
ans:
a =1 0 0
0 1 0
0 0 1
Inverse of the matrix:
clc
clear all
a=[1 2;0 4]
inv(a)
a =1 2
0 4
ans =1.0000 -0.5000
0 0.2500
Reshaping of Matrix.
A=[1 11 8; 4 13 9]
A =1 11 8
4 13 9
EE-218 Computer Programming for Electrical Engineering (N.M.E.E: BE03000191) 29
reshape(A,3,2)
ans =1 13
4 8
11 9
Sparse Matrix
A=[1 0 0;4 1 0; 1 2 8]
X=sparse(A)
X = (1,1) 1
(2,1) 4
(3,1) 1
(2, 2) 1
(3,2) 2
(3,3) 8
Q=full(X)
Q =1 0 0
4 1 0
1 2 8
Output on File Page:
Conclusion:
RUBRICS Unsatisfactory Developing Satisfactory Exemplary
Laboratory (3 to 4 mark) (5 to 6 mark) (7 to 8 mark) (9 to 10 mark)
Assessment. Grade D Grade C Grade B Grade A
EE-218 Computer Programming for Electrical Engineering (N.M.E.E: BE03000191) 30