Caratteri e stringhe
Gli array di caratteri e gli array di stringhe consentono di memorizzare i dati di testo in MATLAB®.
Un array di caratteri è una sequenza di caratteri così come un array numerico è una sequenza di numeri. Un uso tipico è quello di memorizzare brevi porzioni di testo come vettori di caratteri, come
c = 'Hello World'
.Un array di stringhe è un contenitore per porzioni di testo. Gli array di stringhe forniscono un insieme di funzioni per lavorare con il testo come dati. È possibile creare stringhe utilizzando le virgolette doppie, come
str = "Greetings friend"
. Per convertire i dati in array di stringhe, utilizzare la funzionestring
.
Per maggiori informazioni, vedere Text in String and Character Arrays o guardare Using String Arrays for Text Data (Utilizzo degli array di stringhe per i dati di testo).
Funzioni
Argomenti
- Text in String and Character Arrays
Store and manipulate text using either string arrays or character arrays.
- Analyze Text Data with String Arrays
This example shows how to analyze text data with string arrays. It shows how to store, split, and sort text, and how to compute and collect statistics for text in a string array.
- Formatting Text
Compose character arrays or string arrays that include ordinary text and data formatted to your specification.
- Search and Replace Text
MATLAB provides several functions to search for, replace, or extract text in string arrays and character vectors.
- Unicode and ASCII Values
MATLAB stores all characters as Unicode characters. Both strings and character vectors use the same encoding. You can convert characters to their Unicode code values, and numbers to characters.
- Hexadecimal and Binary Values
Specify hexadecimal and binary values either as literals or as text. Hexadecimal and binary literals are stored as integers. You can convert text representing hexadecimal and binary values to numbers, and numbers to text representations.