Separate string and perform math operations in Matlab
Mostrar comentarios más antiguos
Hello I have the following problem:
I have the string
num1 = '02 12 28.27'
I would like to perform operations with the numbers separately but first I need to separate the numbers, for example:
num_1 = 02
num_2 = 12
num_3 = 28.27
I was trying the following:
c = textscan(num1,'%f %f %f', 'Delimiter', ' ')
num1 = c{1}
num2 = c{2}
num3 = c{3}
I just got an empty vector.
Thanks in advance for your help!
1 comentario
Adam
el 14 de Mzo. de 2016
That is strange. If I run your code I get exactly what you are looking for. I wouldn't recommend going down the road of 3 named variables (I would use an array of num(1), num(2), num(3) instead), but that is a different matter entirely!
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!