String Bus Element doesn't work

I created a struct and a bus from the struct. I can create it correctly but it is not usable in a Constant block
% Create Model Struct
car.id = 1;
car.type = "long";
% Create Estimation Data Bus for Simulink Model
car_bus_info = Simulink.Bus.createObject(car);
car_bus = evalin('base', car_bus_info.busName);
The bus is correctly created in Type Editor
Type Editor
Constant value is car
Constant value
and the type is Bus: car_bus
Signal attributes
But I got this error:
Error:Invalid setting in 'DTFoilWinding/Constant10' for parameter 'Value'.
This only happens with string Bus elements. If I don't use car.type, is works

답변 (1개)

Walter Roberson
Walter Roberson 2023년 8월 13일

0 개 추천

You need a String Constant block; https://www.mathworks.com/help/simulink/slref/stringconstant.html as regular Constant Block does not support strings.

댓글 수: 1

Furkan
Furkan 2023년 8월 14일
String Constant blocks accept only strings, but I need a constant block that supports a bus which includes a string bus element. I can't remove that field from the bus because I read structs from json and they have string fields.
Is there any example that a string bus element is used in a bus creator or a bus selector?

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

카테고리

제품

릴리스

R2023a

질문:

2023년 8월 13일

댓글:

2023년 8월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by