[ 선형대수 : matlab ] ch ap 2: 매트랩 환경

107
[ 선형대수 :Matlab] Chap 2: 매트랩 환경

Upload: brock

Post on 05-Jan-2016

148 views

Category:

Documents


0 download

DESCRIPTION

[ 선형대수 : Matlab ] Ch ap 2: 매트랩 환경. 최 윤 정. 학습차례. 매트랩 시작하기 매트랩의 창 매트랩으로 문제 해결하기 작업 결과를 저장하기. 학습차례. 매트랩 시작하기 매트랩의 창 매트랩으로 문제 해결하기 작업 결과를 저장하기. 학습목표. 지난시간에 했습니다. 매트랩 프로그램을 시작하여 명령창에서 간단한 문제를 푼다 . 매트랩의 행렬 사용법을 이해한다 . 다양한 매트랩 창의 이름을 알고 사용한다 . 간단한 행렬을 만들고 사용한다 . - PowerPoint PPT Presentation

TRANSCRIPT

[:Matlab] Chap 1.

[:Matlab]Chap 2: MATLAB for Engineers22In this chapter well get started actually learning how to use the MATLAB program. Well explore the various MATLAB windows and learn how they work, and well solve some problems. Finally, well learn how to save our work. MATLAB for Engineers33In this chapter well get started actually learning how to use the MATLAB program. Well explore the various MATLAB windows and learn how they work, and well solve some problems. Finally, well learn how to save our work. . . . . . .

, . . . .M- .MATLAB for Engineers4 .4MATLAB for Engineers52.1 5MATLAB for Engineers6

Command Window . 6How youll start MATLAB depends on the configuration of your particular computer. In the Windows or Apple operating systems you can click on the desktop icon, or you can use the start menu to find the program. In Unix youll need to type MATLAB at the shell prompt

. .MATLAB for Engineers77MATLAB for Engineers831 .

MATLAB for Engineers9 2.1 . (32)

MATLAB for Engineers102.2 (window)

Command Window10MATLAB for Engineers11: Command Window11(scratch pad) . .MATLAB for Engineers12: Command Window12MATLAB for Engineers13: Command History Window

Command History Window13 . clc . . . .MATLAB for Engineers14:Command History Window34 14MATLAB for Engineers15: Workspace Window

Workspace Window15 .NameValueClassSizeBytesName . .MATLAB for Engineers16: Workspace Window16

Scalar Vector Matrix .(35~36)whos clear .MATLAB for Engineers1717 . .MATLAB for Engineers18 :Current Directory Window18MATLAB for Engineers19 :Current Directory Window

, (array editor) . .MATLAB for Engineers20: Document Window20

Document WindowMATLAB for Engineers21: Document Window21

. .(40)MATLAB for Engineers22 . .

22 .

file new file MATLAB for Engineers23: Editing Window23

file new file .MATLAB for Engineers2424

Save and Run Save and Run . MATLAB for Engineers2525 .

.MATLAB for Engineers262.3 26 . A=3 A 3 A .MATLAB for Engineers27 (Variable)27 . , , (_) . . (keyword) .MATLAB for Engineers28 28MATLAB for Engineers29iskeyword . iskeyword

ans =

'break' 'case' 'catch' 'continue' 'else' 'elseif' 'end' 'for' 'function' 'global' 'if' 'otherwise' 'persistent' 'return' 'switch' 'try' 'while'29 . sin . sin = 3 sin 3 sin .MATLAB for Engineers30 . 30MATLAB for Engineers31 2.2x

31 .(Scalar): (11)(Vector): 1 , (Matrix): 2 MATLAB for Engineers32 (Matrix).32 .MATLAB for Engineers33 >> 9 + 10ans=19

Command PromptResult33

a=1+2

a 1+2 . MATLAB for Engineers34 (=) 34x=3+5

x 3+5 ( x 3+5 ) MATLAB for Engineers35= !!35!!!x=x+1 !! , x 1 , x .MATLAB for Engineers36= ?36 . . (Exponentiation)//

MATLAB for Engineers37 37MATLAB for Engineers38 5*(3+6)= 455*3+6= 21 . !!5*3 + 6= 2138( ) .{ } [ ] . .MATLAB for Engineers395 * (3+4) 5(3+4) .5*6/6*5= 255*6/(6*5)= 139MATLAB for Engineers40: r = 5r : radiush = 10h : height

40

MATLAB for Engineers41 .(47)41[] (wind tunnel) .

PV=nRTn=m/MWMATLAB for Engineers42Example 2.1

42This is example 1.1 in the textbook. 1.Albert Einstein is arguably the most famous scientist of the twentieth century. 2.His simple equation relating energy and matter revolutionized physics. The conversion of matter to energy is what fuels the starsWe can use this equation, E=mc2 to find out how much matter is converted to energy in the sun everyday. .!

: , ? , ,

MATLAB for Engineers431. .43First state the problemFind the amount of matter necessary to produce the amount of energy radiated by the sun everyday V=1000 m3 T=300 K P=100 kPa MW=29 kg/mol R=8.314 kPa m3/kmol K m[kg]=?MATLAB for Engineers442. .44As input, we know that the rate of energy radiation is 385 times 10 to the 24th Joules per second. We also know the speed of light, 3 times 10 to the 8th meters/second. Our output will be the mass converted to energy in kilograms.MATLAB for Engineers453. .

45Pause here and turn on the cursor. This is an easy problem to solve by hand. The hard part is the units conversions. Take the energy radiation rate and multiply by the conversion factor for hours to seconds and the conversion factor from days to hours and finally multiply by one day the amount of time in our analysis. Pause and turn on the pencil.We can see that the units cancel out leaving us with Joules.Pause and turn off the pencil Then rearrange E equals m c squared to solve for m and substitute in the value for energy and the speed of light. .( 52)MATLAB for Engineers464. .

46Of course, at this point we havent learned how to use Matlab, however you can see from the following demonstration just how easy it is to use the command window. MATLAB for Engineers475. .47The Matlab solution matches the hand solution but is it reasonable? Its a really big number could it possibly be right? Consider that the sun masses 2 times 10 to the 20th kg. How long would it take to consume the sun if it continues to burn matter at the rate weve calculated? ( ) .

.MATLAB for Engineers48 48

.MATLAB for Engineers4949

.MATLAB for Engineers5050

() .MATLAB for Engineers5151

. MATLAB for Engineers5252

Hint: . .MATLAB for Engineers5353 .

b= 1:5 b = [1:5] .MATLAB for Engineers54 54

1. . MATLAB for Engineers5555linspacelogspaceMATLAB for Engineers56 56

MATLAB for Engineers5757

10 10 MATLAB for Engineers5858 . : a = [0: pi/10: pi] MATLAB for Engineers5959 . . . (*) (.* ) . MATLAB for Engineers60 60

MATLAB for Engineers6161

. MATLAB for Engineers6262

.* .MATLAB for Engineers6363

* . a b .MATLAB for Engineers6464 .* ./ .^MATLAB for Engineers65 , .57 .65(58): (degree) (radian) , . , .Degree Radian .

* .MATLAB for Engineers66 .66

pi .MATLAB for Engineers6767

* .* .MATLAB for Engineers6868pi . pi . sin(pi)=?MATLAB for Engineers69pi .69 .!MATLAB for Engineers70(Transpose)70

.MATLAB for Engineers7171

table =[degrees;radians] .MATLAB for Engineers7272

1 2 . MATLAB for Engineers7373[] lbf N .

1 lbf=4.4482266 NMATLAB for Engineers74Example 2.2

74This is example 1.1 in the textbook. 1.Albert Einstein is arguably the most famous scientist of the twentieth century. 2.His simple equation relating energy and matter revolutionized physics. The conversion of matter to energy is what fuels the starsWe can use this equation, E=mc2 to find out how much matter is converted to energy in the sun everyday.lbf (0~1000 lbf) N .MATLAB for Engineers751. .75First state the problemFind the amount of matter necessary to produce the amount of energy radiated by the sun everyday 0 lbf 1000 lbf 100 lbf lbf N MATLAB for Engineers762. .76As input, we know that the rate of energy radiation is 385 times 10 to the 24th Joules per second. We also know the speed of light, 3 times 10 to the 8th meters/second. Our output will be the mass converted to energy in kilograms.MATLAB for Engineers773. . 1 lbf=4.4482266 N

100 lbf=? N1000 lbf=? N

77Pause here and turn on the cursor. This is an easy problem to solve by hand. The hard part is the units conversions. Take the energy radiation rate and multiply by the conversion factor for hours to seconds and the conversion factor from days to hours and finally multiply by one day the amount of time in our analysis. Pause and turn on the pencil.We can see that the units cancel out leaving us with Joules.Pause and turn off the pencil Then rearrange E equals m c squared to solve for m and substitute in the value for energy and the speed of light. .( 61)MATLAB for Engineers784. .

78Of course, at this point we havent learned how to use Matlab, however you can see from the following demonstration just how easy it is to use the command window. MATLAB for Engineers795. .79The Matlab solution matches the hand solution but is it reasonable? Its a really big number could it possibly be right? Consider that the sun masses 2 times 10 to the 20th kg. How long would it take to consume the sun if it continues to burn matter at the rate weve calculated?[] (drag) .

MATLAB for Engineers80Example 2.3

80This is example 1.1 in the textbook. 1.Albert Einstein is arguably the most famous scientist of the twentieth century. 2.His simple equation relating energy and matter revolutionized physics. The conversion of matter to energy is what fuels the starsWe can use this equation, E=mc2 to find out how much matter is converted to energy in the sun everyday. . .MATLAB for Engineers811. .81First state the problemFind the amount of matter necessary to produce the amount of energy radiated by the sun everyday(drag) 20000 N r=1*10-6 kg/m3 V=100 mph A=1 m3 Cd MATLAB for Engineers822. .82As input, we know that the rate of energy radiation is 385 times 10 to the 24th Joules per second. We also know the speed of light, 3 times 10 to the 8th meters/second. Our output will be the mass converted to energy in kilograms.MATLAB for Engineers833. .

83Pause here and turn on the cursor. This is an easy problem to solve by hand. The hard part is the units conversions. Take the energy radiation rate and multiply by the conversion factor for hours to seconds and the conversion factor from days to hours and finally multiply by one day the amount of time in our analysis. Pause and turn on the pencil.We can see that the units cancel out leaving us with Joules.Pause and turn off the pencil Then rearrange E equals m c squared to solve for m and substitute in the value for energy and the speed of light. .( 64)MATLAB for Engineers844. .

84Of course, at this point we havent learned how to use Matlab, however you can see from the following demonstration just how easy it is to use the command window. MATLAB for Engineers855. .85The Matlab solution matches the hand solution but is it reasonable? Its a really big number could it possibly be right? Consider that the sun masses 2 times 10 to the 20th kg. How long would it take to consume the sun if it continues to burn matter at the rate weve calculated? 10 . 10 . MATLAB for Engineers86 86

10 . , 6.022 e23 . (6.022 1023 )MATLAB for Engineers8787 .

.

, . MATLAB for Engineers88 88short .

.

4 .MATLAB for Engineers89

89long : 14 bank : 2 format short .MATLAB for Engineers90

90 . .format short eformat long eMATLAB for Engineers91

91 () . MATLAB for Engineers92 (Common Scale Factor)

92format +format ratMATLAB for Engineers93

93 .MATLAB for Engineers942.4 94

.() .MATLAB for Engineers9595

. .MATLAB for Engineers9696 .mat . .dat .MATLAB for Engineers97 save

save my_new_file a bsave my_new_file a b -asciisave my_new_file a b -ascii -doublesave my_new_file a b -ascii -doublesave my_new_file a b -ascii -double -tabs97 M- .File->New->M-file M- . M- . M- .

MATLAB for Engineers98 M-98MATLAB for Engineers99M-

99M- . MATLAB for Engineers100(Comment)100% .

77 M- .MATLAB for Engineers101101[] 1, 2 .

F=maW=FdP=W/t1 AU = 150109 m

MATLAB for Engineers102Example 2.4 : M-

102This is example 1.1 in the textbook. 1.Albert Einstein is arguably the most famous scientist of the twentieth century. 2.His simple equation relating energy and matter revolutionized physics. The conversion of matter to energy is what fuels the starsWe can use this equation, E=mc2 to find out how much matter is converted to energy in the sun everyday. .MATLAB for Engineers1031. .103First state the problemFind the amount of matter necessary to produce the amount of energy radiated by the sun everyday m=721.9 [kg] P=335 [J/s] v = 3.50 [AU/] : 1v = 3.15 [AU/] : 2 a[m/sec2]MATLAB for Engineers1042. .104As input, we know that the rate of energy radiation is 385 times 10 to the 24th Joules per second. We also know the speed of light, 3 times 10 to the 8th meters/second. Our output will be the mass converted to energy in kilograms.MATLAB for Engineers1053. .

105Pause here and turn on the cursor. This is an easy problem to solve by hand. The hard part is the units conversions. Take the energy radiation rate and multiply by the conversion factor for hours to seconds and the conversion factor from days to hours and finally multiply by one day the amount of time in our analysis. Pause and turn on the pencil.We can see that the units cancel out leaving us with Joules.Pause and turn off the pencil Then rearrange E equals m c squared to solve for m and substitute in the value for energy and the speed of light. .( 80)MATLAB for Engineers1064. .

106Of course, at this point we havent learned how to use Matlab, however you can see from the following demonstration just how easy it is to use the command window. . . .M- .MATLAB for Engineers107107