필터 지우기
필터 지우기

close the file with Callback in simulink

조회 수: 2 (최근 30일)
Dhruvilkumar Chavada
Dhruvilkumar Chavada 2022년 11월 4일
답변: Suman 2022년 11월 7일
Hello,
I am using command system('path &') to open a bin file before starting my simulation. (adding this under model properties)
I want to close the same file after completion of my simulation. I tried with fclose('path') under closefcn in model properties but its not working.
Could you tell me how can i close the file with callback function.

채택된 답변

Suman
Suman 2022년 11월 7일
Hi Dhruvilkumar,
As per my understanding, you have opened a ".bin" file using "system(path)" and want to close it automatically after the simulation completes.
The issue, I believe, is with the "system()" operation. The "system()" operation takes a command as parameter and waits for the command to finish execution before returning the exit status. So, "system()" will not stop its execution until the .bin file is closed manually in the background. Please have a look at the following documentation for reference:
Also, "fclose()" expects a File ID as its input parameter which is generated when a file is opened with "fopen()".
Therefore, I suggest you to use "fopen()" to open the .bin file and use "fclose()" in "CloseFcn" callback to automatically close the file after simulation. Please refer to the documentations below:
I hope the above information is helpful to you.
Cheers,
Suman

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Model, Block, and Port Callbacks에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by