-1

Good day

I have a problem in reading a formatted data file using Matlab

Data include integers and real numbers as well characters. Data are separated with a coma (,) and they are split in different lines. See below :

10732, 10711, 10730,'A1',1,1,1, 0.00000E+0,-1.23000E-3,2,'N. SANTA_A1 ',1, 999,1.0000,   0,1.0000,   0,1.0000,   0,1.0000,'            ' (end of first line)
1.25000E-3, 8.11400E-2,   100.00, 3.59000E-3, 4.61720E-1,   100.00, 3.70000E-3, 8.90580E-1,   100.00,1.03918, -75.6446 (end of second line)
1.05000,   0.000,   0.000,   280.00,   280.00,   280.00, 0,      0, 1.10000, 0.90000, 1.10000, 0.90000, 999, 0, 0.00000, 0.00000,  0.000 (end of third line)
1.00000,   0.000,   0.000,   280.00,   280.00,   280.00, 0,      0, 1.10000, 0.90000, 1.10000, 0.90000, 999, 0, 0.00000, 0.00000,  0.000 (end of fourth line)
1.00000,   0.000,   0.000,    60.00,    60.00,    60.00, 0,      0, 1.10000, 0.90000, 1.10000, 0.90000, 999, 0, 0.00000, 0.00000,  0.000 (end of fifth line)

Any idea on that ?

m7913d
  • 10,244
  • 7
  • 28
  • 56
bnelen
  • 1
  • 3
  • Possible duplicate of [How do I read comma separated values from a .txt file in MATLAB using textscan()?](https://stackoverflow.com/questions/35275802/how-do-i-read-comma-separated-values-from-a-txt-file-in-matlab-using-textscan) – GameOfThrows Jun 06 '17 at 12:49

1 Answers1

0

The csvread() function might be helpful here: https://uk.mathworks.com/help/matlab/ref/csvread.html

  • the problem is the multiple lines. I tried textscan but i am not sure how to conver char back to numbers – bnelen Jun 06 '17 at 12:58
  • Oh right, sorry, I didn't notice that. A quick google brings up the `str2double` function as a potential solution. Have you tried that? – Jonathan Page Jun 06 '17 at 14:07