Adding a string value to an array.
Mostrar comentarios más antiguos
Given an array of zeros like so....
0 0 0 0
0 0 0 0
0 0 0 0
Using something like
if something = true
A(2,2) = ("x");
end
Is there a function which will use the str(x) and transform the element in the array at (2,2) to this string?
1 comentario
Stephen23
el 21 de Abr. de 2021
Not really. Arrays are homogenous, the entire array consists of elements of the same class.
As an alternative you could do one of these:
- use a container array (e.g. cell array, but this will make processing numeric data more complex and less efficient)
- use a special value (e.g. NaN, -1)
- store the character value (but this might be easily confused with valid numeric data)
- store a separate logical mask and/or string/char array.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Characters and Strings en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!