2.12 Zeichenketten (Strings)

Eine Zeichenkette ist ein Array von Zeichen (characters). Jedes Zeichen wird intern durch eine Zahl dargestellt.

>> txt='Ich lerne jetzt MATLAB'

txt =

Ich lerne jetzt MATLAB

>> num=double(txt)

num =

  Columns 1 through 12

    73    99   104    32   108   101   114   110   101    32   106   101

  Columns 13 through 22

   116   122   116    32    77    65    84    76    65    66

>> char(num)

ans =

Ich lerne jetzt MATLAB

>> whos txt num
  Name      Size         Bytes  Class

  num       1x22           176  double array
  txt       1x22            44  char array

Grand total is 44 elements using 220 bytes

>> txt(2:5)

ans =

ch l

>> strcat(txt(12:22),txt(1:11))

ans =

etzt MATLABIch lerne j



Peter Arbenz 2008-09-24