10-2 使用一??????多個??

ڭ̥iΨؤkxshӦr@ܼƤCĤ@ؤkOϥΤGr}C]Two Dimensional Character Arrays^AT{CӦr]YC@C^פ@ˡA_hNbur굲ɤWťզrAHTOC@rꧡۦPסAҦpG

Example 1: 10-rPr/string201.mdepartments = ['ee '; 'cs '; 'econ'] % `Nu[]vBu;vΪťզrϥ departments = ee cs econ

Ъ`NezTӦrꧡU 4 Ӧr]tťզr^cAGקU 4A@ΰOjpGQ|Ӧ줸ա]Y 3 Ӧr4 Ӧr2 bytes = 24 bytes^C

ĤGإixshӦr@ܼƪkAOϥ char OAҦpG

Example 2: 10-rPr/string202.mdepartments = char('ee', 'cs', 'econ') % `Nu()vΡu,vϥ departments = ee cs econ

dҩұo쪺GMe@ӽdҬO@˪C

bqGr}CXrɡAOnϥ deblank OӲťզrAҦpG

Example 3: 10-rPr/string203.mdepartments = char('ee', 'cs', 'econ'); dept1 = departments(1,:); % (1,:)NĤ@C dept2 = deblank(dept1); % ϥ deblank OӲťզr len1 = length(dept1) % ܼ dept1 len2 = length(dept2) % ܼ dept2 len1 = 4 len2 = 2

pGrꪺ׮tƤjAϥΤGr}CxshӦrANyOŶOCѨMDhOϥΡu}CvACDnOΨxsPAƩP@ܼƤAѲĤQGMԲӤСAbȧ@P`²满pUG

Example 4: 10-rPr/string204.mcellData = {'ee', 'cs', 'econ'}; % H}C celldata xshӦr dept = cellData{3} % LXĤTӦr]ϥΤjA^ dept = econ

ڭ̥iϥ cellstr ONr}Cഫ}CG

Example 5: 10-rPr/string205.mdepartments = char('ee', 'cs', 'econ'); cellData = cellstr(departments); leng = length(cellData{2}) % ܲ}C cellData ĤGӤ leng = 2

bWҤAcellstr OӱNr}C departments ഫ}C cellData xsAӭɦbr}C departments ťզrAwQA] leng Ȭ 2C

YnN]trꪺ}Cഫ@몺Gr}CA٬OiHϥ char OAҦpG

Example 6: 10-rPr/string206.mdept1 = char('ee', 'cs', 'econ'); % dept1 O@Ӧr}C cellData = cellstr(dept1); % N dept1 ন@ӲȰ}C cellData dept2 = char(cellData); % N cellData ഫr}C dept2 isequal(dept1, dept2) % dept1 M dept2 O_۵ ans = 1


MATLAB{]pGJg