C-MEX S-Functionで文字列をパラメータとして受け渡すことはできますか?
12 views (last 30 days)
Show older comments
MathWorks Support Team
on 17 Aug 2012
Commented: guygyuggfff
on 17 Jun 2021
C-MEX S-Functionのパラメータに文字列を与えて、S-Function内部で文字列を使用する方法を教えてください。
Accepted Answer
MathWorks Support Team
on 17 Aug 2012
ssGetSFcnParamで取得したmxArray構造体のデータからmxGetStringで文字列を取得することで、S-Function内で文字列として扱うことができます。
次のコマンドでパラメータを文字列として受け渡すC-MEX S-Functionのデモを起動できます。
sfcndemo_runtime
sfcndemo_sfun_rtwdwork
最初のデモではS-Functionブロックのパラメータ'++','SumTimesGain'等が文字列として渡されており、mxGetStringで文字列を取得しています。
2番目のデモはS-Functionがマスク化されていますが、「RTW Identifier」、「RTW Storage Class」、「RTW Type Qualifier」で入力(選択)された文字列が変数id, sc, tqとしてパラメータ入力されています。
注意点として、パラメータを使用したS-Functionを含むモデルからコード生成を行う場合、TLCファイルが必要になります。
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!