필터 지우기
필터 지우기

Read in data from an external file during RTW

조회 수: 1 (최근 30일)
Sandeep
Sandeep 2012년 10월 23일
I'm using RTW to generate a c-code (dll), which is used in ADAMS to simulate the model. I'm using a c code in my Simulink model to read in body parameters from an external file. I would like to read the variabls from an excel file using a .m code. However, I do not want to create a new dll everytime the variables are changed. I want the dll to read the variables everytime I run the simulation, rather than the variable values getting compiled during the code generation. I would appreciate if I could get some help with this.
Thanks.
  댓글 수: 3
Walter Roberson
Walter Roberson 2012년 10월 23일
I would have thought RTW would imply that you were using an operating system other than MS Windows (the only family of operating systems that support COM servers) ?
Sandeep
Sandeep 2013년 1월 11일
Kaustubha, I am reading a text file as suggested by Walter. However, struggling to get the c-code to read a particular column of data based on an inout passed from MATLAB. Can you help? I can send you my code? Thanks

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

채택된 답변

Walter Roberson
Walter Roberson 2012년 10월 23일
You would find this easier if you used a text file instead of an excel file. Microsoft Excel format (especially the binary format) is not a simple one (if memory serves me correctly); you would need to include fair portions of code such as has been written for OpenOffice.

추가 답변 (1개)

Sandeep
Sandeep 2012년 10월 24일
Thanks guys. Walter, I'm using a text file at the moment. If you daone this sort of stuff in the past, would you be kind enough to provide me an example? Cheers mate.
  댓글 수: 2
Walter Roberson
Walter Roberson 2012년 10월 24일
I have never worked with RTW, but what I have seen of it looked as if it supported standard C buffered I/O routines such as fopen() and fscanf(). If not directly in the modelling language, then due to the fact that it is C and those are standard features of C for all but embedded device purposes.
Sandeep
Sandeep 2013년 1월 11일
Walter, thanks for your comments mate. I have go a code which scans a text file. But i'm struggling to make a few changesto it. I was wondering if you any experience in C.

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by