Matlab Ni-Chun

Matlab Ni-Chun - Command Window Introduction to Matlab TA:...

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

View Full Document Right Arrow Icon
Introduction to Matlab TA: Ni-Chun Wang nichun@ee.ucla.edu 2010/4/1 Discussion 1A, 1D, 1F (Ni-Chun Wang) 2 Command Window type here 2010/4/1 Discussion 1A, 1D, 1F (Ni-Chun Wang) 3 Workspace You don’t need to declare the variables. All the variables being used can be found in the workspace. You can check the values of the variables in the workspace. 2010/4/1 Discussion 1A, 1D, 1F (Ni-Chun Wang) 4 Delete Variables >>clear var_A % delete the variable var_A >>clear var_A var_B % delete both var_A and var_B >>clear var* % delete all variables that start with the letters “var” >>clear % delete ALL variables (All text after a percent sign (%) is taken as a comment statement.)
Background image of page 1

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

View Full DocumentRight Arrow Icon
2010/4/1 Discussion 1A, 1D, 1F (Ni-Chun Wang) 5 Arithmetic operators • addition + subtraction multiplication * division / power ^ (ex: a^b means a b ) • Complex number –U s e i or j to express – ex: a = 2 + 3j; b = 3 - j*5; 1 2010/4/1 Discussion 1A, 1D, 1F (Ni-Chun Wang) 6 Some basic math functions abs(x) Absolute value sqrt(x) Square root log(x) Natural log log10(x) Log (base 10) exp(x) Exponential e x sin(x), cos(x), tan(x) sine, cosine, tangent asin(x), acos(x), atan(x) Inverse sine, cosine, tangent 2010/4/1 Discussion 1A, 1D, 1F (Ni-Chun Wang) 7 Help • In the command window >> help <function name> • Press F1 under command window, a help browser will show up. 2010/4/1 Discussion 1A, 1D, 1F (Ni-Chun Wang) 8 Vector variables • Row vector >> x = [1 2 3 4 5 6] >> x = [1,2,3,4,5,6] • Column vector >> x = [1;2;3;4;5;6] >> x = [1 2 3 4 5 6]’ ( means conjugate transpose) Separating elements by spaces or commas specifies elements in different columns , whereas separating elements by semicolons specifies elements in different
Background image of page 2
2010/4/1 Discussion 1A, 1D, 1F (Ni-Chun Wang) 9 Build a Matrix 1. >> X = [1 2 3; 4 5 6; 7 8 9]; % 3x3 matrix 2. >> x1 = [1 2 3]; >> x2 = [4 5 6]; >> x3 = [7 8 9]; >> X = [x1; x2; x3]; % 3x3 matrix 3. >> y1 = [1 4 7]’; >> y2 = [2 5 8]’; >> y3 = [3 6 9]’; >> Y
Background image of page 3

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

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 9

Matlab Ni-Chun - Command Window Introduction to Matlab TA:...

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

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