我有一个关于八度或matlab数据后处理的问题。我有从fluent导出的文件如下所示:
"Surface Integral Report"
Mass-Weighted Average
Static Temperature (k) crossplane-x-0.001 1242.9402
crossplane-x-0.025 1243.0017
crossplane-x-0.050 1243.2036
crossplane-x-0.075 1243.5321
crossplane-x-0.100 1243.9176我想使用八度/matlab进行后处理。如果我先逐行读取,并且只将带有“十字-x-”的行保存到一个新文件中,或者直接将这些行中的数据保存到一个矩阵中。由于我有许多类似的文件,我可以通过调用他们的标题来制作情节。但是我很难识别包含字符“十字-x-”的线条。我试着做这样的事情:
clear, clean, clc;
% open a file and read line by line
fid = fopen ("h20H22_alongHGpath_temp.dat");
% save full lines into a new file if only chars inside
txtread = fgetl (fid)
num_of_lines = fskipl(fid, Inf);
char = 'crossplane-x-'
for i=1:num_of_lines,
if char in fgetl(fid)
[x, nx] = fscanf(fid);
print x
endif
endfor
fclose (fid);有人会在这个问题上说点什么吗?我是否使用了正确的功能?谢谢。
发布于 2016-08-09 22:46:47
以下是处理特定文件的快速方法:
>> S = fileread("myfile.dat"); % collect file contents into string
>> C = strsplit(S, "crossplane-x-"); % first cell is the header, rest is data
>> M = str2num (strcat (C{2:end})) % concatenate datastrings, convert to numbers
M =
1.0000e-03 1.2429e+03
2.5000e-02 1.2430e+03
5.0000e-02 1.2432e+03
7.5000e-02 1.2435e+03
1.0000e-01 1.2439e+03https://stackoverflow.com/questions/38824942
复制相似问题