Separate string and perform math operations in Matlab
古いコメントを表示
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 件のコメント
Adam
2016 年 3 月 14 日
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!
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Characters and Strings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!