Saji Kuttan
2018-11-03 10:08:43 UTC
Hi,
I have a text file which is attached. The file has some header lines, that
have to be skipped. I am trying to read the data in the file with different
choices such as load, importdata, and fscanf. I think only fscanf can be
used here. Even with fscanf, I have some problems.
I used fscanf as :
*for i=1:33[d,c1,c2,t]=fscanf(fid," %d %s %s %f", "C");printf("%d %f\n",
d,t)x=fgetl(fid); % to skip remaining part of the lineend*
This code is not perfect because:
(1) I have to manually count the number of lines in the text file. I don't
know to apply automatic EOF.
(2) There are some missing data, given as "..." at the end. Here the
numeric field is changed to character. How it can be solved?
So please tell me how to read this file and save the data into different
variables.
--
Saji P K
Assistant Professor
Department of Physical Oceanography
School of Marine Sciences,
Cochin University of Science and Technology,
Fine Arts Avenue
Kochi - 682016
Phone : (O) 0484 2863206 (Mob) 9744000804
Email : ***@gmail.com
Web : http://dpo.cusat.ac.in/faculty/pks/index.html
I have a text file which is attached. The file has some header lines, that
have to be skipped. I am trying to read the data in the file with different
choices such as load, importdata, and fscanf. I think only fscanf can be
used here. Even with fscanf, I have some problems.
I used fscanf as :
*for i=1:33[d,c1,c2,t]=fscanf(fid," %d %s %s %f", "C");printf("%d %f\n",
d,t)x=fgetl(fid); % to skip remaining part of the lineend*
This code is not perfect because:
(1) I have to manually count the number of lines in the text file. I don't
know to apply automatic EOF.
(2) There are some missing data, given as "..." at the end. Here the
numeric field is changed to character. How it can be solved?
So please tell me how to read this file and save the data into different
variables.
--
Saji P K
Assistant Professor
Department of Physical Oceanography
School of Marine Sciences,
Cochin University of Science and Technology,
Fine Arts Avenue
Kochi - 682016
Phone : (O) 0484 2863206 (Mob) 9744000804
Email : ***@gmail.com
Web : http://dpo.cusat.ac.in/faculty/pks/index.html