15-4 ��������������������������?

C@Ө禡bBɡAέӧO@OAu@ŶM MATLAB 򥻤u@ŶάOL禡u@ŶOۿWߪA]PŶܼƬOWߡA|ۤvTCoǦbPu@ŶܼơA٬uϰܼơv]Local Variables^C@ӨAϥΰϰܼƤwມ@{]pݨDAɭԬFܼƪǻAڭ̥iΡuܼơv]Global Variables^AbϥΥܼƤeAڭ̥ݥiܼƫŧiA榡pUG

global variable1 variable2 ...
ҦpGڭ̦b禡 func6.m ŧiF@ӥܼ XAæLXȡAFunc6.m epUG >> type func6.m function func6 global X % ܼƫŧi X = X + 2; fprintf('The value of X in "func6" is %g.\n', X);

禡SXMJALuOŧiܼ XAN X ȥ[ 2AæLXȡCզ禡AiJpUG

>> global X % b򥻤u@Ŷiܼ x ŧi >> X = 2; >> fprintf('The value of X in the base workspace is %g.\n', X); The value of X in the base workspace is 2. >> func6; The value of X in "func6" is 4. >> fprintf('The value of X in the base workspace is %g.\n', X); The value of X in the base workspace is 4.

ѦiA@ X QŧiܼƫANiHbPŶAsΧܦP@ӥܼ X ȡC

ݪ`NOGкɶq֥ΥܼơIܼƷ|ϵ{y{zAy{κ@xCYz@wnΥܼơAп`UChG

t~Ab˵u@ŶܼƮɡAݿJ whos globalA~ܥܼơAҦpG

>> whos global Name Size Bytes Class X 1x1 8 double array (global) Grand total is 1 elements using 8 bytes

bMܼƮɡAclear X u|Mbثeu@Ŷܼ XAYnMҦu@Ŷܼ XAhݨϥ clear global XC


MATLAB{]pGJg