131A_1_Matlab

131A_1_Matlab - Matlab Basic Commands TA: Ni-Chun Wang...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
1 2008/5/21 Matlab Basic Commands TA: Ni-Chun Wang EE131A nichun@ee.ucla.edu 2008/5/21 Help • In the command window >> help xxx (xxx: the function name, topics) • Press F1 under command window, a help window will show up.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 2008/5/21 Fundamental Expression • You don’t need to declare the variables. All variables are by default stored in double precision format. • addition + subtraction – multiplication * division / exponential ^ (ex: a^b means a b ) 2008/5/21 Fundamental Expression • Complex number –Use i or j to express • If you don’t want the value be shown in the command window, append a semi-colon(;) after each expression. 1
Background image of page 2
3 2008/5/21 Some basic math functions Inverse sine, cosine, tangent asin(x), acos(x), atan(x) sine, cosine, tangent sin(x), cos(x), tan(x) Uniformly distributed Pseudo-random number generator between [0,1] rand Exponential e x exp(x) Log (base 10) log10(x) Natural log log(x) Square root sqrt(x) Absolute value abs(x) 2008/5/21 Vector variables • Row vector >> x=[1 2 3 4 5 6] • Column vector >> x=[1;2;3;4;5;6] or >> x=[1 2 3 4 5 6]’ % means transpose
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 2008/5/21 Vector addressing >> x(3)=2; % assign 2 to be the 3rd element of vector x >> x(3)=[]; % delete the 3rd element of x >> x(2:4) % the 2nd~4th elements of the vector x >> x(1:2:5) % the 1st, 3rd, 5th elements of x >> x(end:-1:3) % start from the last element, count down by 1, and stop when reaching the 3rd element 2008/5/21 Build a Matrix 1.
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 15

131A_1_Matlab - Matlab Basic Commands TA: Ni-Chun Wang...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online