排列的矢量和矩阵在文本文件



我的ASCII文件有一个纬度向量,这些纬度值的索引将纬度值与共享相同索引的数据联系起来。

即,如果给定:

latitude[x=0,1,2,3] = 10, 20, 30, 40
longitude[y=0,1,2] = 15, 25, 35
pressure[z=0,1] = 1000, 950

GPHeight_A[z][x] = var_0, var_1, var_2为3个经度提供该变量,其压力和纬度分别用z和x表示。

对于这个简单的例子,GPHeight_A[0,0] = a, b, c意味着

a经度为15,压力为1000,纬度为10

b经度为25,压力为1000,纬度为10

c经度为35,压力为1000,纬度为10

GPHeight_A[1,3] = d, e, f对于这个简单的例子来说意味着

d经度为15,压力为950,纬度为40

e经度25,压力950,纬度40

f经度35,压力950,纬度40

有20个这样的列(表示经度值)对应于每个纬度。我想把这个文本文件管理成这样的文本文件。它由三列组成。第一列是纬度,第二列是经度,第三列是文本文件中这些纬度和日志的值。

附加文本文件!

我得到这些数据的经纬度范围是(22-39N,60-79E)。

请指导我如何按照我的要求安排这些数据。

提前感谢您的努力。

文件

GPHeight_A[0][0], -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999
GPHeight_A[0][1], -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999
GPHeight_A[0][2], -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999
GPHeight_A[0][3], -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999
GPHeight_A[0][4], -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999
GPHeight_A[0][5], -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999
GPHeight_A[0][6], -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999
GPHeight_A[0][7], -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999
GPHeight_A[0][8], -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999
GPHeight_A[0][9], -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999
GPHeight_A[0][10], -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999
GPHeight_A[0][11], -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999
GPHeight_A[0][12], -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, 28, 28, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999
GPHeight_A[0][13], 27, 34, 38, 37, 33, 35, 33, 35, 25, 24, 32, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999
GPHeight_A[0][14], 29, 33, 35, 33, 34, 36, 36, 36, 30, 29, 35, 36, -9999, -9999, -9999, -9999, -9999, -9999, -9999, -9999
GPHeight_A[0][15], 30, 33, 32, 34, 33, 33, 34, 36, 39, 38, 39, 41, 45, -9999, -9999, -9999, -9999, -9999, -9999, -9999
GPHeight_A[0][16], 32, 32, 35, 36, 34, 36, 35, 36, 38, 45, 47, 45, 46, 52, -9999, -9999, -9999, -9999, -9999, -9999
GPHeight_A[0][17], 34, 36, 37, 37, 38, 39, 40, 42, 41, 45, 57, 50, 50, 54, -9999, -9999, -9999, -9999, -9999, -9999
 % - Read source file.
 fSpec = ['GPHeight_A[%f][%f]', repmat( ', %f', 1, 20 )] ;
 data  = textscan( fileread( 'Forward file.txt' ), fSpec ) ;
 % - Get pressure from lookup table of pressures and first z+1 (indexing in
 %  MATLAB starts at 1). Update the code if z can vary within an input file.
 pressures = 1000 : -100 : 100 ;                % To adjust to your setting.
 pressure = pressures(data{1}(1)+1) ;
 % - Extract/aggregate data.
 latId = data{2} + 1 ;                          % x + 1
 GP    = horzcat( data{3:end} ) ;

相关内容

  • 没有找到相关文章

最新更新