Notation in Matlab
Matrices in Matlab
Moving arrow keys allow you to see the previous equations youve typed.
 = gives a list for a matrix
; = gives a row
, = separates elements from column to column
Ex. M=[1, 2, 3; 4 5 6]
No commas are fine f
Trapezoid rule: I = (b-a) f(a)+f(b)/(b-a)
1/third Simpsons Rule.
Then do composite 1/3 rule. Cannot use composite if not an odd number of points, even
number of intervals.
Simpsons 3/8ths rule: Third order
The 2,1 matches the 1,2
The elements are symmetric across the diagonal.
Everything is 0 except for the diagonal.
1s along diagonal, 0s everywhere else.
< less than
<= less than or equal
> greater than
>= greater than or
~= not equal
Matlab will give a 1 or 0 for true or untrue statements. If you say 5>4 for whatever variable
represents 5 and 4, then youll receive a 1 fo
Strings in Matlab and fprintf
Fprintf(The string is of %.42\n, truncate)
Since truncate is text in the string, use single quotes
Since youve used two percent signs, you need to create two truncate. Ex: truncate
The 0.4 doesnt say its givin
Writing Code in Matlab
This is good for generating a dice roll.
randi ([2,10],1,5) Now you have a range of 2-10, one row, range of 5
B=reshape(A,4,2) changes the 2x4 matrix to a 4x2.
Go to th
Matrices in Matlab
Qualities of a Matrix
A = 
1. Size (1x1)
2. Content (1)
3. Name (matrix A)
B = [1,3,6]
1. Size (2x3) -or- 6 elements. (elements are individual components of the matrix defined by
their position. i.e: B(1,1) is row 1,
There are two different norms: vector norms and matrix norms.
if x = [2 10 -3]
The norm formula is |x|p = (sum(i=1,n)|x|p)1/p
The one norm of x is |x|1 = (|2|1 + |10|1 + |-3|1 )1 This is the sum of the absolute values of the
diagena I' L/
(:9 O 3
it's called I
[11-[A] = [A] '[I] unique property of
linear systems #251 + M a;
3 Q 263$
"i 1X1 2 ght? How will we isolate x on the other side?
Fall 2015 Test 1 Review Rev. 1 (10/20/2015)
Drs. Simmons and Gustafson
1. Know everything from the Quiz. Especially logic, loops, decision structures, input, fprintfing, plotting,
finding, loading, and saving.
2. Matrices and Parametric Functions
Fall 2015 Test 3 Review Rev. 1 (11/15/2015)
Drs. Simmons, and Gustafson
1. Know everything from the Quiz and Test 1. Especially loops. No really - we mean it.
a. Know how to calculate the mean and sum of squares of data residuals for a vecto
Base 10 has numbers 0-9
If we have a number 24,565 can be re-written as
10010 holds 2 as the base.
1x2^4 + 0x2^3 + 0x2^2 + 1x2^1 + 0x2^0
16 + 0 + 0 +2 = 18
Ex. Given 254, you can rewrite it as
The largest number to 254
Special Method of curve-fitting (connecting the dots)
You pick the parameters of our function to ensure this curve goes through every point.
Our r2 value must be close to 1. (St Sr / St).
The residual is 0 for interpolation.
For and while
A for loop is counted for. It repeats a specific number of times.
A while loop repeats until it reaches a condition. Keep repeating while the statement is
Format for for loop (REVIEW FOR QUIZ)
for loop variable
Differentiation in Matlab
If we use x1 which is (xi-1), this is the backward finite difference.
If we use x3 which is (xi+1), this is our forward finite difference
If we use x1 and x3, were using central difference
Anything with letters, numbers, underscores, but cannot start with a number.
Everything on the right-hand side of the equal sign must be defined. Left hand side is always the
variable. If you set x=4, you cannot say 4=x.