MATLAB POLYSPACE RELEASE NOTES Manuel d'utilisateur Page 153

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 240
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 152
Other Data Structures
joins the strings horizontally and produces
h=
Hello world
The statement
v = [s; 'world']
joins the strings vertically and produces
v=
Hello
world
Notethatablankhastobeinsertedbeforethe'w' in h and that both words
in
v have to have the same length. The resulting arrays are both character
arrays;
h is 1-by-11 and v is 2-by-5.
To m anipulate a body of text containing lines of different lengths, you have
two choices—a padded character array or a cell array of strings. When
creating a character array, you must make each row of the array the same
length. (Pad the ends of the shorter rows with spaces.) The
char function do es
this padding for you. For example,
S = char('A','rolling ','stone','gathers', 'momentum.')
produces a 5-by-9 character array:
S=
A
rolling
stone
gathers
momentum.
Alternatively, you can store the text in a cell array. For example,
C = {'A';'rolling';'s tone';'gathers';'mom entum.'}
creates a 5-by-1 cell array that requires no padding because each row of the
array can have a different length:
4-15
Vue de la page 152
1 2 ... 148 149 150 151 152 153 154 155 156 157 158 ... 239 240

Commentaires sur ces manuels

Pas de commentaire