15-1 ������

²aAZ]Scripts^YO@ӰɦW m ɮסA䤺]tF MATLAB UثOAڭ̥iHb MATLAB OUJɮתDɦWAMATLAB Yiv@bɮפҦOANϩڭ̦b MATLAB OvCJoǫO@CѴXGҦ{dҡAOHZe{C

ҦpG]bثeؿU@Mɮסuscript01.mvAڭ̥i type Oܨ䤺eApUG

>> cd d:\matlabBook\MATLAB{]pGJg\15-Mɮס >> type script01.m clear all % MҦܼ x = [1 4 -2 3 -1 -5]; for i = 1:length(x), if x(i)>0, fprintf('x(%g) = %g is positive\n', i, x(i)); else fprintf('x(%g) = %g is negative or zero\n', i, x(i)); end end

script01.mAb MATLAB OUJ script01 YiG

>> script01 x(1) = 1 is positive x(2) = 4 is positive x(3) = -2 is negative or zero x(4) = 3 is positive x(5) = -1 is negative or zero x(6) = -5 is negative or zero

榹{ZA۷b MATLAB OUUF script01.m ̪C@COAҲܼͪƤ]sb MATLAB 򥻤u@Ŷ]Base Workspace^AiҦpUG

>> whos Name Size Bytes Class i 1x1 8 double array x 1x6 48 double array Grand total is 7 elements using 56 bytes

Hint
z]ib@禡Is@{ZAɩҲܼͪƧY|bӨ禡u@ŶC

{Z̾AΩI²Ʃʰ{XALä䴩JοX޼ơ]Input/Output Arguments^AӥBѩҲܼͪƧX{b򥻤u@ŶAeyܼƪл\ӳy{~͡C}oǩZIAiΨ禡ANbU`СC

MӡAZ]LuIGѩҲܼͪƧOdb򥻤u@ŶAҥHܮeiܼ˵ΰC

M ɮ׬O@ӤrɡAҥHziHΦUؤrs边hקLAOobxsɮ׮ɡAݥHrҦxsC~AMATLAB b Windows Mac xWA紣ѤF@ӤتuM ɮ׽s边v]M-File Editor^AziHI MATLAB O file/open UԦAӶ} M ɮ׽s边At@ا֪kAhOb MATLAB OuJuedit filename.mv άOuopen filename.mvCҦp A} Script01.mAiJpUG

>> edit script01.m

M ɮ׽s边|HPCܵѡBrBrBΤ@{XAbϥΤW۷KC

Hint
ƹWAM ɮ׽s边]O@Ӱ]Debugger^AϥΨ䰣\AiԨѲĤQCu{vC


MATLAB{]pGJg