MATLAB MATLABMATrix LABoratory FortranCleve Moler C C JavaMathworks
MATLAB의 일반적인 사항 • MATLAB=MATrix + LABoratory • Fortran(Cleve Moler) => C, C++, Java(Mathworks) • 행렬 데이터가 기본 연산 • M-file을 사용한 프로그래밍 • Toolbox-신호 처리, 통계학, 영상 처리, 제어, fuzzy logic, 재정, 화학 공정 • 심볼로 이루어진 수식을 계산하는 기호계산 • GUI( Graphical User Interface) 프로그래밍 • SIMULINK Chapter 1 Uiduk University
MATLAB 5. x – 화면 구성 Chapter 1 Uiduk University
MATLAB – 사칙 연산 Operation Symbol Example Addition, a + b + 3 + 22 Subtraction, a – b - 90 – 54 Multiplication, a • b * 3. 14 * 0. 85 Division, a b / or 56/8 = 856 Exponentiation, ab ^ 2^8 EX 1) EX 2) EX 3) >> 3 + 22 >> 3. 14 * 0. 85 >> 2 ^ 8 ans = 25 256 >> 90 - 54 >> 56 / 8 >> ((1. 043 + 2. 01) * 3)^2 ans = 36 Chapter 1 2. 6690 7 83. 8873 Uiduk University
MATLAB – Variables Variable Naming Rules Comments/Examples 대소문자 구별 Cost, cost, Co. St, COST 는 서로 다른 변수 최대 31 글자까지 허용 반드시 글자로 시작하여야함 First. Val = 5 (O) 3 As = 7 (X) 쉼표는 허용되지 않음 v, a = 5 (X) 마침표는 쓰지 말 것 v. a = 5 ( ) EX 4) EX 5) EX 6) >> a = 5 >> c = (a * b)^a / b >> Age = 22 a= c= Age = 22 5 4050000 >> Day. Of. Year = 365 >> b = 6 Day. Of. Year = 365 b= 6 >> Day. Of. Age = Age * Day. Of. Year Day. Of. Age = 8030 Chapter 1 Uiduk University
MATLAB – Special Variables Special Variable Description ans 결과를 나타내는 기본 변수 pi 원주율 flops 부동 소수점 계산 수행 횟수 inf 무한대 (1 / 0) i, j i=j= realmin 최소의 + 숫자 realmax 최대의 + 숫자 EX 7) EX 8) EX 9) >> pi >> realmin ans = 3. 1416 2. 2251 e-308 >> inf >> realmax ans = Inf Chapter 1 0 + 1. 0000 i 1. 7977 e+308 Uiduk University
MATLAB – Complex Number Declaration a bi, a bj Related Function Description Magnitude of x (= a bi) = abs(x) angle(x) Angle in radians of x (= a bi) = tan-1(b/a) real(x) Real part of x (= a bi) = a imag(x) Imaginary part of x (= a bi) = b conj(x) Complex conjugate of x (= a + bi) = a - bi EX 10) EX 11) EX 12) >> a = sqrt(3) + 1 j >> theta = angle(a) >> r = real(a) a= theta = r= 1. 7321 + 1. 0000 i 1. 7321 >> m = abs(a) >> degree = theta * 180 / pi >> i = imag(a) m= degree = i= 2. 0000 Chapter 1 0. 5236 30. 0000 1 Uiduk University
MATLAB – Mathematical Functions Exponential Function Description exp(x) Exponential log(x) Natural logarithm log 10(x) Base 10 logarithm log 2(x) Base 2 logarithm and floating-point dissection pow 2(x) 2 x sqrt(x) Square root EX 13) EX 14) EX 15) >> exp(1) >> log 10(2) >> pow 2(4) ans = 2. 7183 16 >> log(2) >> log 2(2) >> sqrt(3) ans = 0. 6931 Chapter 1 0. 3010 1 1. 7321 Uiduk University
MATLAB – Mathematical Functions Trigonometric Function Description sin(x) Sine cos(x) Cosine tan(x) Tangent csc(x) Cosecant of x = 1 / sin(x) sec(x) Secant of x = 1 / cos(x) cot(x) Cotangent of x = 1 / tan(x) asin(x) Inverse sine of x = arcsin(x) = sin-1(x) acos(x) Inverse cosine of x = arccos(x) = cos-1(x) atan(x) Inverse tangent of x = arctan(x) = tan-1(x) sinh(x) Hyperbolic sine of x = sinh(x) = (ex – e-x) / 2 cosh(x) Hyperbolic cosine of x = cosh(x) = (ex + e-x) / 2 tanh(x) Hyperbolic tangent of x = tanh(x) = (ex - e-x) / (ex + e-x) Chapter 1 Uiduk University
- Slides: 14