c file name from grt generated code

조회 수: 6 (최근 30일)
Chirag Jagadish
Chirag Jagadish 2018년 9월 26일
댓글: Chirag Jagadish 2019년 1월 11일
I have a tlc file which accesses the c file name generated through grt.tlc
%assign modelFileName = LibGetSourceFileSection(fileIdx, "Name")
Some times without any reason, the above code returns the complete path of the file and at most times only the name of the c or header file.
How can i filter out the complete path details and get only the file name from the string that is returned above?
Example Most of the time, modelFileName is populated as file name.c or file name.h Some times, it comes back as D:\MyGenFiles\StorageLoc\_sharedutils\<c file name>.c
How do i remove the "D:\MyGenFiles\StorageLoc\_sharedutils\" part from the string above in tlc.
I have to do this only in the tlc environment.
  댓글 수: 1
Chirag Jagadish
Chirag Jagadish 2018년 9월 26일
this relates to handling strings in tlc

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

채택된 답변

Mark McBroom
Mark McBroom 2019년 1월 11일
Probably the easiest approach is to write a simple MATLAB function that takes as an argument the modelFileName, then uses fileparts() to strip off the directory name and returns the file name. Then call this MATLAB function from TLC using the built-in TLC function FEVAL().
  댓글 수: 1
Chirag Jagadish
Chirag Jagadish 2019년 1월 11일
Exactly what i did. I made a new m file for this and made the FEVAL call it. FEVAL call from tlc makes only the first parameter available in the tlc. So i made a suitable m file and called it.
Thanks for the answer though

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Simulink Coder에 대해 자세히 알아보기

제품


릴리스

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by