我正在使用我编写的 python 脚本来获取一些标准输入ls并加载该路径描述的文件中的数据。它看起来像这样:
ls -d /path/to/files/* | python read_files.py
Run Code Online (Sandbox Code Playgroud)
这些文件根据其中包含的数据具有特定的名称结构,但全部存储在同一目录中。我想要使用的文件具有名称结构A<fileID>_###.txt(其中###始终是一些 3 位数字)。我只需将上面的内容稍微更改为 .a 即可完成仅获取以 A 开头的文件ls -d /path/to/files/A*。但是,某些文件有一个名为 B 的后缀标志(因此文件看起来像A<fileID>_###B.txt),我不想包含这些文件。
所以,我的问题是,有没有办法排除那些以数字结尾的文件...B.txt(或者只包含以数字结尾的文件)?我想到了一些大意:
ls -d /path/to/file/R*%d.txt
Run Code Online (Sandbox Code Playgroud)
仅包含以数字结尾并后跟文件扩展名的文件,但找不到任何此类文档。
我有一些相对完整的观测数据,但在矩阵中包含一些 NaN 值,matlab我想使用它们将它们插值到更均匀间隔的网格interp2
因此,为了简单起见,假设我有一个完整的(无 NaN 值)矩阵,以及一个看起来像这样的矩阵:
A = [ 1 2 3 4;
2 3 2 NaN;
0 2 3 4;
0 NaN 4 5 ]
Run Code Online (Sandbox Code Playgroud)
作为B完整C矩阵,interp2不会接受具有 NaN 值的输入矩阵。所以如果我做这样的事情:
[AI,BI] = meshgrid(a,b) %# matrices to interpolate data to, arbitrary
CI = interp2(A,B,C,AI,BI) %# interpolation, A has NaN values
Run Code Online (Sandbox Code Playgroud)
我收到错误:
Error using griddedInterpolant
The coordinates of the input points must be finite values; Inf and NaN are not permitted.
Run Code Online (Sandbox Code Playgroud)
任何人都可以提出不妨碍我的数据的解决方案或合理的解决方法吗?