Elementbyelement operations
Symbol
Operation
Form
Examples
+
Scalararray addition
A + b
[6,3]+2=[8,5]

Scalararray subtraction
A b
[8,3]5=[3,2]
+
Array addition
A + B
[6,5]+[4,8]=[10,13]

Array subtraction
A B
[6,5][4,8]=[2,3]
.*
Array multiplic
ENGR 103
ComputerAided Analysis Tools for
Engineers
Department of Electrical Engineering
The City College of The City University of
New York (CCNY)
Spring 2014
Session 2
Dr. Nidal Khrais
Arrays
Arrays
Basic building block in MATLAB
Classes of arrays in
Array Addressing
The colon operator selects individual elements, rows,
columns, or 'subarrays' of arrays. Here are some
examples:
v(:) represents all the row or column elements of
the vector v.
v(2:5) represents the second through fifth elements;
that i
Useful Array Functions
size(A): Returns a row vector [m n] containing the
sizes of the m x n array A.
sort(A): Sorts each column of the array A in ascending
order and returns an array the same size as A.
sum(A): Sums the elements in each column of the arr
For example, typing x = 0:2:8 creates the
vector x = [0,2,4,6,8], whereas typing x =
0:2:7 creates the vector x = [0,2,4,6].
To create a row vector z consisting of the values
from 5 to 8 in steps of 0.1, type z = 5:0.1:8.
If the increment q is omitted, it
Multidimensional Arrays
You can create a multidimensional array by
first creating a twodimensional array and
then extending it.
Suppose you want to create a threedimensional array whose first 2 pages are
4 6 1
5 8 0
3 9 2
6 2 9
0 3 1
4 7 5
First cr
MatrixMatrix Multiplication
In the product of two matrices AB, the number of
columns in A must equal the number of rows in B. The
rowcolumn multiplications form column vectors, and
these column vectors form the matrix result. The
product AB has the same
ENGR 103
ComputerAided Analysis Tools for Engineers
Department of Electrical Engineering
The City College of The City University of New
York (CCNY)
Fall 2014
Session 1
Overview
Dr. Nidal Khrais
High level language for technical computing
Stands for MATri
Saving and Retrieving Your Workspace
Variables
To continue a MATLAB session at a later time, you must use the save (Export
Function) and load (Import Function) commands
Typing save causes MATLAB to save the workspace variables (variable names, their
sizes
Complex Number Operations
The number c1 = 1 2i is entered as follows: c1 = 12i.
An asterisk is not needed between i or j and a number,
although it is required with a variable, such as c2 = 5
i*c1.
Be careful. The expressions
y = 7/2*i (i is in the num
ENGR 103
ComputerAided Analysis Tools for Engineers
Department of Electrical Engineering
The City College of The City University of New
York (CCNY)
Fall 2014
Session 7
Model Building and Regression
Dr. Nidal Khrais
Model Building and Regression
Introduct
Programming Style
1. Comments section
a. The name of the program and any key
words in the first line.
b. The date created, and the creators' names
in the second line.
c. The definitions of the variable names for
every input and output variable. Include
de
Examples of power functions.
can pass through the origin but only if m > 0 (positive)
As y = bxm = b/xm Hyperbolic for negative m
y mx b
y bx m
y be mx
ye e
y pp x
x
150
y pm x 2
2
25
400
350
20
300
100
250
ye
ypp
ypm
15
10
200
150
50
100
5
50
0
5
0
5
x