2つのMatlabインスタンスを実行しています。最初は.txt
ファイルにデータを書き込んでいますが、もう1つはそのデータを読み込んでいます。更新中のtxtファイルの読み込みを中止 - Matlab
.txtファイルがアクセスされていることを確認して例外/エラーをスローする方法はありますか?
2番目のMatlabインスタンスがデータを読み取るが、Horzcatなどのエラーが発生することがわかりましたが、その.txtファイルも更新されていました。書き込みインスタンスで
fName = 'Test.txt' ;
% Matlab Instance1
mat = 1 + (2-1)*randn(100000,5) ; mat = mat.' ;
[fid, fMsg] = fopen(fName, 'at') ;
if fid~=-1, fprintf(fid, '%.10f\t%.10f\t%.10f\t%.10f\t%.10f\r\n', mat(:)) ; end
fclose(fid);
% Matlab Instance2
fid = fopen(fName);
C = textscan(fid, '%f %f %f %f %f', 'Delimiter', '\t');
C=cell2mat(C);
fclose(fid);
このトピックを読むこのトピックを読むhttp://stackoverflow.com/questions/3451343/atomically-creating-a-file-lock-in-matlab-file-mutex – Cheery