1. 程式人生 > 實用技巧 >matlab學習3

matlab學習3

matlab學習3

用於儲存matlab工作區變數的檔案叫做記憶體變數檔案 .mat 也叫MAT檔案

文字和字元

當您處理文字時,將字元序列括在雙引號中。可以將文字賦給變數。

文字/字元序列
t = "Hello, world";

如果文字包含雙引號,請在定義中使用兩個雙引號。

q = "Something ""quoted"" and something else."

q = 

    "Something "quoted" and something else."
字串陣列
>> A = ["a","bb","ccc"; "dddd","eeeeee","fffffff"]

A = 

  2×3 string 陣列

    "a"       "bb"        "ccc"    
    "dddd"    "eeeeee"    "fffffff"

>> strlength(A)

ans =

     1     2     3
     4     6     7
字元陣列使用單引號
資料型別為 char 的字元陣列
>> seq = 'GCTAGAATCC';
whos seq
  Name      Size            Bytes  Class    Attributes

  seq       1x10               20  char    
使用方括號串聯字元陣列
>> seq2 = [seq 'ATTAGAAACC']

seq2 =

    'GCTAGAATCCATTAGAAACC'