1. 程式人生 > >MATLAB中的大括號

MATLAB中的大括號

1.在定義幾個變數或字串時如:
    1.student = struct('name',{'Annie'},'scores',{70,89,100,45})定義構架函式
    2.A = {[1,4,3;0,5,8;7,2,9]} %定義元胞陣列
    3.prompt = {'Enter matrix size:','Enter colormap name:'};
    title = 'Input for peaks function';
    lines = 1;
    def = {'20','hsv'};
    answer = inputdlg(prompt,title,lines,def);%定義輸入資訊對話方塊
2.定義某一圖形或其他物件屬性時:(%統計圖形,分位點)
    clf;
    v = 4;
    p = 0.95;
    q = chi2inv(p,v);
    x = 0:0.1:15;
    kf_4 = chi2pdf(x,v);
    plot(x,kf_4,'b'),hold on
    xxf = 0:0.1:q;
    yyf = chi2pdf(xxf,v);
    fill([xxf,q],[yyf,0],'g')
    text(q*1.01,0.01,num2str(q))
    text(10,0.16,['/fontsize{16} x~{/chi}^2' '(4)'])
    text(1.5,0.08,'/fontname{隸書}/fontsize{22}置信水平 0.95')
    text(12,0.008,'/downarrow','fontsize',22)
    text(11,0.03,'/fontname{隸書}/fontsize{22}拒絕域')
3.  cell變數裡面cell的標號
    比如 a = cell(m, n) ;
    a{1}  = a(1,1); a{2} = a(2,1); ......a{m} = a{m,1}; a{m+1} = a(1,2), a{m+2} = a(2,2),  a{m*n} =a(m,n);