Passing strings between subsystems
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi,
I'm building up strings dynamically in several subsystems, both using Embedded Matlab blocks and Level-2 M-File blocks. Now, my problem is that I would like to pass these strings to a custom-made interface block. The only solution I was able to find so far was to split the strings into an array of ASCII codes, pass them to the interface module then re-contruct the string in that module. Needless to say that , although it works, it is not the most elegant solution.
I was wondering if somebody would have a better idea as of how to solve this problem in a more elegant way? The resulting model will be used by RTW-EC to generate embedded code out of it.
Many thanks in advance!
댓글 수: 0
채택된 답변
Desiree
2011년 7월 19일
Passing the ASCII representation of characters is one way to achieve this. However if Level-2 MATLAB S-Functions are used you won't be able to generate code with Embedded Coder anyway (only if you inline the function). A better way would be to use C Code S-Functions. One example on how to pass character arrays between 2 S-Functions written in C can be found on the MathWorks website: http://www.mathworks.com/support/solutions/en/data/1-Z5HKT/index.html The main idea here is to pass a pointer to the character array through Simulink signals.
추가 답변 (1개)
Walter Roberson
2011년 7월 19일
I do not have experience myself in those products, but my recollection from a Question several months ago is that it was said that there is no direct support for passing strings through a model, and that the indirect mechanism was the one you arrived at, converting the characters to numeric form.
참고 항목
카테고리
Help Center 및 File Exchange에서 String에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!