MATLAB Answers

Character Variables in Simulink

46 ビュー (過去 30 日間)
Jon
Jon 2011 年 11 月 3 日
編集済み: John Kelly 2015 年 2 月 27 日
I think this should be easy, but it isn't for some reason. What am I missing?
I want to pass a character variable from one block to the next.
Code:
busname.busobject = 'characterVariable';
I've also tried declaring 'char' as extrinsic and using:
busname.busobject = char('characterVariable');
but I keep getting this error:
Expression 'busname' for type of data 'busname' (#71) did not evaluate to a valid type.
Error evaluating properties of Simulink.Bus object 'busname' in workspace 'base' (used by block 'SimulinkModelName/MATLAB Function Block Name/ SFunction ').
DataType 'char' did not resolve to a valid data type.
Any help is appreciated.

  0 件のコメント

サインインしてコメントする。

採用された回答

Kaustubha Govind
Kaustubha Govind 2011 年 11 月 3 日
編集済み: John Kelly 2015 年 2 月 27 日
Characters are not valid Simulink signal types - only numeric, fixed-point, enumerated and bus types (with elements of supported type) are supported. See Data Types Supported by Simulink.

  0 件のコメント

サインインしてコメントする。

その他の回答 (1 件)

Seth Popinchalk
Seth Popinchalk 2011 年 11 月 22 日
While characters are not a type you can use on a signal line, you can cast them to an Int8 and then work with that. No blocks in Simulink support characters, so I'm guessing you are using S-functions. If that is the case, you can always cast the input signals back to char and work with them inside the S-functions without problem.

  0 件のコメント

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by