How to extract coordinate from the header files?
Show older comments
Hi everyone.
I have 6 headerlines and then data. I want to extract the only the coordinate numbers in the first headerline.
Example data as below and also as attached
Lat: 6.4931, Lon: 99.6067, Parameter: z(m)
Depth (m): 22.45
Constituents included: m2 s2 k1 o1
Time start: 00:00, 1. 1.1993
Time step (min): 60.00
Time Series length (hours):236664
01-Jan-1993 00:00:00 -0.0946
01-Jan-1993 01:00:00 -0.3369
01-Jan-1993 02:00:00 -0.5110
01-Jan-1993 03:00:00 -0.5776
Please see the script below:
clc;clear all; close all;
delim = ' '; % space delimited
% delim = '\t'; % tab delimited
% delim = ','; % comma delimited
%Input File
fid=fopen('aa__file002.txt');
% A = textscan(fid,'%s %n','Delimiter',delim); % read file;
A = textscan(fid,'%s %s %f','HeaderLines',6); % read file;
Headerlin1 = textscan(fid,'%s %f%s %s %f%s %s %s',1,'Delimiter','delim');
fclose(fid); % close file
Any help regarding the problem are really appreciated.
Accepted Answer
More Answers (0)
Categories
Find more on Data Import and Export in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!