n
このファイルは、最初の行がヘッダーで、その後にデータを含む行が続く出力ファイルです。この最初のデータ セットの後に、異なる値を持つより類似したデータ セットが続きます。
direction 1
、などのすべてのデータセットについて、このファイルから2番目と3番目の列を読み取りたいですdirection 2
。現在、関数内で次のコード行を使用して、以下に示すようにデータを読み取ります。
fid = fopen(output_file); % open the output file
dotOUT_fileContents = textscan(fid,'%s','Delimiter','\n'); % read it as string ('%s') into one big array, row by row
dotOUT_fileContents = dotOUT_fileContents{1};
fclose(fid); %# close the file
%# find rows containing 'SV'
data_starts = strmatch('SV',...
dotOUT_fileContents); % data_starts contains the line numbers wherever 'str2match' is found
nDataRows=data_starts(2)-data_starts(1)-1;
ndata = length(data_starts); % total no. of data values will be equal to the corresponding no. of 'str2match' read from the .out file
%# loop through the file and read the numeric data
for w = 1:ndata
%# read lines containing numbers
tmp_str = dotOUT_fileContents(data_starts(w)+1:data_starts(w)+nDataRows);
%# convert strings to numbers
y = cell2mat(cellfun(@(z) sscanf(z,'%f'),tmp_str,'UniformOutput',false)); % store the content of the string which contains data in form of a character
data_matrix_column_wise(:,w) = y; % convert the part of the character containing data into number
%# assign output in terms of lag and variogram values
lag_column_wise(:,w)=data_matrix_column_wise(2:6:nLag*6-4,w);
vgs_column_wise(:,w)=data_matrix_column_wise(3:6:nLag*6-3,w);
end
上記の出力ファイルに星が表示されていない場合、この関数はうまく機能していました。ただし、上記のような出力ファイルの 1 つに星が含まれており、その場合、上記のコードは失敗しました。列 2 と列 3 を正しく読み取ることができるように、データ内の星を処理するにはどうすればよいですか?