# MATLAB 개요와 응용

• View
87

0

Embed Size (px)

DESCRIPTION

MATLAB . | >> . . MATLAB , , , . | >> . Enter , . , . - PowerPoint PPT Presentation

Transcript

• MATLAB

1

• 1 */55 MATLAB , , , . | >> . Enter , . , . .

1

• 1 */55 (Command Window) (,) , Enter . . >> . >> , . . , ... Enter ( 4096 )

1

• 1 */55(;) % , clc Enter , , (;) . . . % (comment) Enter . % , . , .clc . clc , . .

1

• 1 */55 (Command History Window)Command History , .Command History . MATLAB Command History .Command History (dragging), Enter . (double click) . delete Edit Delete Selection . Delete Selection .

1

• 1 */55 MATLAB :) Windows \ \( \) . , (left division) (right division) , (3 ) .

+5+3-5-3*5*3 /5/3 \(\)5\3(=3/5)^5^3(53 )

1

• 1 */55 MATLAB , . , . .

1 , 23, ( )4

1

• 1 */55 (1/3)>> 4*50+3*100+10^2-400/2ans = 400>> 2^5/(2^5-1)ans = 1.0323>> 2*(sqrt(5)-1)/(sqrt(5)+1)^2-1ans = -0.7639>> 10*acos(-1)ans = 31.4159>> x=2; y=6+x, x=y+7y = 8x = 15>> exp(3); % e3>> log10(10^5); % log10 105 : 1. 2. 3. , 4. , ;() ,() % ,

1

• 1 */55MATLAB Enter , ans= () . (2/3)

1

• 1 */55 (1/3)MATLAB (default) (short ).>> 4+5/3+2ans = 7.6667 format , format . help format . MATLAB .

format short0.001> 290/7ans = 41.4286format long0.001> 290/7ans = 41.42857142857143

1

• 1 */55 (2/3)

format short e .>> 290/7ans = 4.1429e+001format long e 15 .>> 290/7ans = 4.142857142857143e+001format short g . 5>> 290/7ans = 41.429format long g . 15.>> 290/7ans = 41.4285714285714format bank .>> 290/7ans = 41.43format compact format looseformat compact

1

• 1 */55 >> sqrt(64) % ans = 8>> sqrt(50+14*3) % ans = 9.5917>> sqrt(54+9*sqrt(100)) % ans = 12>> (15+600/4)/sqrt(121) % ans = 15MATLAB library , . (argument) . ) sqrt(x) : . sqrt, x. , , . .

1

• 1 */55MATLAB Help Window .

sqrt(x)>> sqrt(81)ans = 9nthroot(x, n) x n.(x , n ) >> nthroot(80, 5)ans = 2.4022exp(x)(ex)>> exp(5)ans = 148.4132abs(x)>> abs(-24)ans = 24log(x). e (ln)>> log(1000)ans = 6.9078log10(x) 10 >> log10(1000)ans = 3.0000factorial(x) x!(x )>> factorial(5)ans = 120

1

• 1 */55MATLAB sin(x), cos(x), tan(x), cot(x) asin(x), acos(x), atan(x), acot(x). (degree) sind(x), cosd(x), tand(x), cotd(x) asind(x), acosd(x), atand(x), acotd(x). (hyperbolic trigonometric function) sinh(x), cosh(x), tanh(x), coth(x). pi .

sin(x)sind(x) x (x ) x (x )>> sin(pi/6)ans = 0.5000cos(x)cosd(x) x (x ) x (x )>> cosd(30)ans = 0.8660tan(x)tand(x) x (x ) x (x )>> tan(pi/6)ans = 0.5774cot(x)cotd(x) x (x ) x (x )>> cotd(30)ans = 1.7321

1

• 1 */55 (rounding function)

round(x) ()>>round(3.4)ans = 3fix(x)0 >>fix(2.6)ans = 2ceil(x) >>ceil(2.2)ans = 3floor(x) >>floor(-2.25)ans = -3rem(x, y)x y .>>rem(13,5)ans = 3sign(x)Signum , x>0 +1, x>sign(5)ans = 1

1

• 1 */55 , ( ) . , MATLAB . . , . (assignment operator) = . (1/3)

1

• 1 */55 Enter , . . . , , Enter . . (2/3)

1

• 1 */55 . , (argument) . (3/3)

1

• 1 */55 , MATLAB 7 63(6.0 31) . ) var, temp_1, temp_2, x, y, ave_1 , , _ , , , . , _ . . :) AA, Aa, aA, aa (: cos, sin, exp, sqrt, ) . , . MATLAB 17 . , . . iskeyword . ) break, case, catch, continue, else, elseif, end, for, function, global, if, otherwise, persistent, return, switch, try, while(variable)

1

• 1 */55 , , . iskeyword . MATLAB , . ans eps 2-522.220410-16. ) 1.0 i, jInf (Infinity)NaNNot-a-Number. 0/0 pi=3.1415926535897realmax, realmin, nargin, nargout . pi, eps, inf . i j .(variable)

1

• 1 */55 , (.) Enter . , .>> Class_1=20; Class_2=15; Class_3=14; Class_4=17; Total_Number=240;>> ave = (Class_1 + Class_2 + Class_3 + Class_4) / Total_Number * 100 ans = 27.5 >> ave=(Class_1+Class_2+Class_3+Class_4)/Total_ ??? ave=(Class_1+Class_2+Class_3+Class_4)/Total Error: The input character is not valid in MATLAB statements or expressions.>> a=4; b=3; sum=a+b sum = 7>> a=7; sum sum = 7a Excel sum .

1

• 1 */55 (Command Window) .

clear .clear x y z x, y, z .who .whos , .

1

• 1 */55 clc (Clears the Command window)exist(var) var quit MATLAB helpwin help lookfor ( ) cd

1

• 1 */55MATLAB = (assignment) (replacement) .) >> x=5 % x 5 (). >> x = x + 10 % x 10 x . = , :>> x*2=6??? x*2=6 |Error: The expression to the left of the equals sign is not a valid target for an assignment. =

1

• 1 */55MATLAB i j , . >> c=10-2i % c=10-2j c = 10.0000 - 2.0000i i * , i * . i , i * i . (1/3)

1

• 1 */55MATLAB i j . >> i=10; im=4; % i 10 >> c=1+0.2i % 0.2i c = 1.0000 0.2000i >> c=1+0.2*i % 0.2 i(=10) c=3 >> c=1+im*i % im(=4) i(=10) c=41 (2/3)

1

• 1 */55>> exp(pi/2*i) % e(/2)i ans=0.0000+1.0000i>> i^2 ans = -1>> (-2+4i)*(-2-4i)ans = 20>> c1=1-2i; c2=3*(2-sqrt(-1)*3); c3=sqrt(-2); c4=(c1+c2)/c3ans = - 7.7782 - 4.9497i>> c = 1-2i;>> abs(c), angle(c) ans =2.2361ans = -1.1071>> conj(c), real(c), imag(c) ans = 1.0000 + 2.0000i ans = 1ans = -2 (3/3)

1

• 1 */55MATLAB . MATLAB .

1

• 1 */55MATLAB

MATLAB . , , .MATLAB M , MAT , MEX , diary , textM (script) (function) , Editor WINDOWS ASCII . m. ) test.m

1

• 1 */55(script) , . , MATLAB . , , (Figure Window) . , , . , MATLAB . .m M- . (global variable) workspace .(Script)

1

• 1 */551

1