MATLAB
60 flashcards · Other · by Minh Đức
when you dont want to show the result on the screen, what do you do?
put a semicolon at the end
in matlab, what is the beginning index of an array
1
if we want to multiply, divide, exponential 2 array that have same sizde, what should we do
.* ./ .^
funtion for vector's geonometric length
norm (v)
number of element in a vector
length(v)
how to select column 1 and 3 of matrix v
v(:, [1,3])
length() của 1 matrix thì return cái j
số ptử lớn nhất của row hoặc column
cách tạo 1 vector bắt đầu từ a, kết thúc tại b, step là n
a:n:b
cách tạo 1 vector bắt đầu từ a, kết thúc tại b, số phần tử là n
linspace(a,b,n)
sort matrix v theo column
sort (v)
sort matrix v theo row
sort(v,2)
funtion for ex
exp(x)
phương trình cho arc tan(x)
atan(x)
equation for ln(x) and log(x)
log(x) and log10(x)
how to find roots
write coefficient in a vector a then roots(a)
which search path MATLAB use on your computer
path where MATLAB is installed
hàm max() của 1 vector return cái j
the biggest number in that vector
funtion max() of a matrix return what?
the row contain the largest number of each column
what does it mean find(x)
return all the indexs that have elements rather than 0
[a b c] = find(a)
a: row indices of the non zero element of a b: column indices of the non-zero element of a c : no-0 element of a
meaning of [x k] = max(a) if a is a vector
store the max value of a in x store the index of x in k
meaning of sum (a)
return a row vector contain the sum of each column
size (w) return what
[m n] where m is row of a matrix n is column of matrix
in default, what is the direction of traversal in matlab
through column
if in a matrix have a complex number, what happend
max(), min(), sum() will treat each element as absolute magnitude
if A and B are 2 matrix A .* B = A * B' = A * B =
element by element dot( A. B) cross(A,B)
when we can use matrix multiplication ( cross product)
when column of this matrix is equal to the row of that matrix
when you want to write sin cos tan for angle that is in radius
sind, cosd, tand
cách viết a:n:b theo linspace (a,b,n)
a:(b-a)/(n-1):b
write linspace as a:n:b
linspace(a,b, (b-a)/n + 1)
write a function to find the maximum element in each row of matrix A
max(A') '
cách tạo 1 matrix D có 3 dimension với matrix A,B,C là các layer của nó
D = cat(3,A,B,C)
how to find the largest number in each layer of 3-D matrix D
max(D) and it will return the max number of each layer
how to find the largest number in the whole 3-D matrix D
max(max(D))
muốn tính cho từng segment ta dùng
.*
muốn tính total của các segment ta dùng
dot(a,b)
cách giải 1 phương trình 3 ẩn trở lên
vector A store all the coefficient , 1 equation is 1 row vector B store all the right-hand side result in the same row with A ans = A \ B
when multiply element by element an vector with an matrix, the vector have to
vector need to have same row or same column with matrix
bài cho tìm L,r để cost min, mà không cho biết L,R
cho L = 0, tính R xong viết vector chứa R viết vector chứa L viết công thức cost tìm min
M = (F *r) . n
dot( cross(F,r), n)
form for anonymous function
fhandle = @(arglist) expr
how to plot a function
fplot(@y, [ range ])
cách giải 1 pt f(x) = 0 trong matlab
ta viết pt, sau đó dùng fzero để tìm x
cách để tìm max 1 function y = f(x) và x tương ứng
đầu tiên t cần tính được y sau đó dùng [y0 index] = max(y) x = x(index)
if rank(a) = rank([a b]) = number of unknown rank(a) != rank([a b]) rank(a) = rank([a b]) != number of unknown
unique solution ( use \ ) there is no solution infinite solution ( use rref)
khi nào thì dùng pinv
underdetermined system
what is a consistent system, an inconsistent system
consistent system: has a solution inconsistent : has no solution
các bước để bân bằng hóa học bằng matlab
cân bằng từng nguyên tố cho hệ số nguyên tố cuối = 1 a\b ans = ans/(x1)
when there is infinite solution use what
rref or pinv
when there is uniquie solution use
inv or \
how to solve a linear problem with constraint
use simlp
what simlp will return and how to write it
the minimum of a funciton simlp(f,a,b)
how to find A and B in simlp function
Ax <= B
how to find max of function of f(x)
g(x) = -f(x) max = fminbnd(g,x1,x2)
cách chia dư a cho btrong matlab
mod(a,b)
cách để nhập input là số vào matlab
x = input('prompt')
cách để nhập input là string vào matlab
x = input('prompt' , 's')
how to preallocate array A of N number in matlab
A = zeros(n)
how to preallocate a char array of n characters
a = blanks(n)
how to preallocate array A when dont know the numbers of elements
A = []