I am trying to import a data set that contains the latitude, longitude, and the thickness of the Earth's crust at that coordinate. The difficult part is the formatting of the data within the text file. It is fomatted as follows:
column 1 ; column 2
latitude_1 ; crustal thickness w/ sediment_1
longitude_1 ; crustal thickness w/o sediment_1
latitude_2 ; crustal thickness w/ sediment_2
longitude_2 ; crustal thickness w/o sediment_2
latitude_3 ; crustal thickness w/ sediment_3
longitude_3 ; crustal thickness w/o sediment_3
And it continues like this for a few thousand data points.
I would like to be able to have the latitudes in one column, the longitudes in once column, and the crustal thicknesses in their own columns.
I have tried all sorts of stuff, and have searched through a ton of forum posts, but I have not been able to figure this out.
Here is what I have so far, but this method has not produced usable results. More specifically, the for loops don't always pick out the correct values. Latitude should never be greater than 90, yet the for loop is producing values greater than 100. I dont know how. I wouldnt mind abandoning the for loop method if I can find a way to textscan the data into columns.
fid = fopen('nam-data-xl_2.txt');
N = 3902;
formatSpec = '%s%f%f';
Mat = textscan(fid,formatSpec,N);
for i = 1:2:3902
j = 1;
coordinates = [lati; longi];
l = 1;
for iii = 2:2:3902
crsti(l) = thick(iii);
l = l+1;