Convert single string with many numbers to vector
29 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Pati Stan
el 31 de Jul. de 2019
Comentada: Stephen23
el 7 de Ag. de 2019
I have the following string
hue = '10 20 30 40 50';
That I want to turn into a vector of those 5 values
hue_vec = [10 20 30 40 50];
How can I do this? Thanks in advance!
0 comentarios
Respuesta aceptada
madhan ravi
el 31 de Jul. de 2019
hue_vec = str2double(regexp(hue,'\d+','match'))
1 comentario
madhan ravi
el 31 de Jul. de 2019
If you have decimals then the expressions would be:
hue_vec = str2double(regexp(hue,'\d*[\.]?\d*','match'))
Más respuestas (3)
Ver también
Categorías
Más información sobre Numeric Types en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!