필터 지우기
필터 지우기

How to check files in a specified directory through Simulink?

조회 수: 5 (최근 30일)
Oswin Hulsebos
Oswin Hulsebos 2020년 6월 10일
댓글: Oswin Hulsebos 2020년 6월 11일
I'd like to detect the availability of a file in the simulation of a Simulink model, but I cannot find a working function for this.
I'm using a MATLAB script which detects the availability of a file in a specified directory, like './Data/'. This script makes use of the function
exist(f{n}, 'file')
, but I've also tried
isfile(f{n})
, and a less convenient solution using dir as
fileinfo = dir(out);
any(ismember({fileinfo.name}.', f{n}))
In these options f{n} either represents only the filename, or the filename including the path, depending on the chosen method. Out specifies the path.
In MATLAB each of these methods provides the desired results. However, when this is put in a MATLAB Function Block in Simulink, these functions are not compatible for code generation. Is there any function which has this functionality in Simulink, or is there a workaround? The solution must be compatible with code generation.

답변 (1개)

Mark McBroom
Mark McBroom 2020년 6월 11일
As long as you don't need to generate C code from your SImulink model, use the coder.extrinsic function to notify Simulink that you don't need to geneate simulation code for the unsupported function.
  댓글 수: 1
Oswin Hulsebos
Oswin Hulsebos 2020년 6월 11일
Eventually C code would need to be generated. I did see some C functions providing this functionality, and I believe I've also read something about being able to use C in Simulink. Preferably I wouldn't go that route, as I do not have much experience on that subject yet. However, if there's no other option within Simulink's functions I guess that'll be the way to go.

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

카테고리

Help CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by