matlab chapter 2

¡Supera tus tareas y exámenes ahora con Quizwiz!

single element replacement

>> mat(i, j) = ___;

mat(:,N) or mat(M,:)

all elements in particular column or row

3D

array

reshape(mat,m,n,p)

changes M × N × P array to m × n × p

fliplr(mat)

changes first column to last, etc. (flips left-to-right)

flipud(mat)

changes first row to last, etc. (flips up-to-down)

row vector to column vector

r = 1:3; c = r'

random real numbers on the open interval (0,1)does not include 0 or 1

rand(N) or rand(M,N)

random integers on the closed interval [A,B] includes A and B

randi([A,B],N) or randi([A,B],M,N)

repelem(mat,m,n)

repeats each element of matrix 'mat' m × n times, forming a new mM × nN matrix

repmat(mat,m,n)

repeats matrix 'mat' m × n times, forming a new mM × nN matrix

mat(row, col)

reports element in arow,col position

mat(#)

reports element in position increasing columnwise

greater_than = mat > x

returns a logical array with true (1) or false (0) for each element

any(mat)

returns a row vector of logical 1s and 0s if any element in each column is nonzero or 'true'

all(mat)

returns a row vector of logical 1s and 0s if every element in each column is nonzero or 'true'

false(M,N,'logical')

returns an M×N logical matrix of 'false' 0s

true(M,N,'logical')

returns an M×N logical matrix of 'true' 1s

mat(greater_than)

returns elements of matrix mat > x

sum(greater_than)

returns number of elements of mat > x

find(mat > x)

returns position of elements of matrix mat > x using linear indexing

flip(mat)

row vectors l-to-r; col vectors u-to-d; matrix u-to-d;

Defined for vectors - equivalent to multiplying a row vector by a column vector

row*col = [a1 a2 a3] * [b1 b2 b3]' = a1b1 + a2b2 + a3b3

0D

scalar

[r, c] = size(mat)

stores length of each dimension

numel(mat)

total number of elements

Empty Matrix

vec = []

colon vector

vec = first:last vec = first:step:last

space filling vector

vec = linspace(first, last, num) vec = logspace(first, last, num)

"One" Matrix

vec = ones(N) vec = ones(M,N) M=column N=row

"Zero" Matrix

vec = zeros(N) vec = zeros(M,N) M=column N=row

space vector

vec= [1 2 3 4]

comma vector

vec= [1,2,3,4]

semicolon column vector

vec= [1; 2; 3; 4]

1D

vector

2D

matrix

length(mat)

largest of all dimensions

mat(M, end) or mat(end, N)

last element in particular column or row

matrix enter separated

mat = [1 2 3 4 5 6]

matrix using semicolon

mat = [1 2 3; 4 5 6; 7 8 9] mat = [1:3; 4:6; 7:9]

Row/Column replacement

mat(:, j) or mat(i, :) = ___;

Extend Matrix

mat(:, j+_) or mat(i+_, :) = ___;

Subset replacement

mat(i1:i2, j1:j2) = ___;

multiplication dot operator

mata .* matb = [a1 a2 a3] .* [b1 b2 = [a1b1 a2b2 a3b3] b3]

division dop operator

mata .* matb = [a1 a2 a3] ./ [b1 b2 = [a1/b1 a2/b2 a3/b3] b3]

exponent dot operator

mata .^ b = [a1 a2 a3]b = [a1b a2b a3b]

scalar multiplication

mata*b = [a1 a2 a3]*b = [a1b, a2b, a3b]

scalar division

mata/b = [a1 a2 a3]/b = [a1/b, a2/b, a3/b]

scalar addition

mata±b = [a1 a2 a3]±b = [a1±b, a2±b, a3±b]


Conjuntos de estudio relacionados

Informatik 04 - AWTest Java Kontrollstrukturen

View Set

Chapter 14: Power, Influence, and leadership

View Set

Psych Stat Chapter 4 Practice Problems

View Set

ICND2 - STP, RSTP Questions (Start with definition)

View Set

Biology: Life Cycles of Ferns and Pines

View Set