필터 지우기
필터 지우기

impossible to accede to a file with fopen

조회 수: 1 (최근 30일)
Damien DUDUYER
Damien DUDUYER 2013년 5월 22일
With Matlab 2012b + simulink, I use a Matlab function to write data in a .txt file. Sometime, a problem to accede to the file occurs. The problem is that a window appears: title of the window is "Remote". The window contain the following text (in french): "Impossible to accede to the file "Elapsed_Real_Time.txt. Continue to try to communicate? YES/NO"
When the window appears, it stops the access to the file and the data is not written anymore.
The model was working with matlab 2007. Is it necessary to a code line to avoid the problem.
function Matlab_to_WM(u)
coder.extrinsic('dlmwrite');
coder.extrinsic('fopen');
coder.extrinsic('fclose');
fid=double(0);
fid=fopen('D:\damien\Echange_donnees_System\Elapsed_Real_Time.txt', 'w');
if fid ~= -1 && fid ~= 2
dlmwrite('D:\damien\Echange_donnees_System\Elapsed_Real_Time.txt' , u , 'newline', 'pc');
end
fclose('all');
end

답변 (1개)

Iain
Iain 2013년 5월 22일
Do not use fopen then try to use dlmwrite/csvwrite/etc.
  댓글 수: 1
Damien DUDUYER
Damien DUDUYER 2013년 5월 23일
I forgot to specify that the .txt file is read by an other software. The txt file is used for data exchange. That's why I check whith fopen if the file is accessible or not. Without using fopen, I will have an error when dmlwrite try to write the data in the same time that the other software have opened the file to read the data.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Low-Level File I/O에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by