0

I have a string with six values:

datastring = A, 12229, 1480413555450, 139,1473389, 012,3362331, -001,7571955 

where the first one is a letter and the rest are float number, I would like to get the numeric values using:

data=textscan(datastring,'%s %f %f %f %f %f','Delimiter',',');   

The problem is, as you see, that both the decimals, and the different values, are separate by ,, so do you have any idea how I could do that?

PS: I also tried with delimiter being ', ', that is with an space, but isnt working neither.

1 Answers1

2

You can convert the ", " to something else that wont be in the string, then convert the remaining "," to a "." and then use your original code but change the delimiter to "something else", e.g.

tempStr = regexprep ( regexprep ( datastring, ', ', '# ' ), ',', '.' );
data=textscan(tempStr,'%s %f %f %f %f %f','Delimiter','#') 
matlabgui
  • 5,642
  • 1
  • 12
  • 15