Simulink string input implementation

hello team,
When i am using string in the if loop in simulink i am having issue.
Edit :
For every TR case, i want output A = "National" or "State" instead of A = 11.
But it is not showing error when A = 11 replaced by A = "National".
How to resolve it.
In case if possible, what data type to be used in Model explorer for this input ?
Thank you
P.S : i am new to simulink.

댓글 수: 9

Walter Roberson
Walter Roberson 2020년 12월 25일
Either reconfigure state variable A to be numeric or else assign in string values such as A = "11"
Watch out for the possibility that TR is not any of those values.
Note: you are using Simscape, which has some noticable differences from most of Simulink.
NIKHIL
NIKHIL 2020년 12월 28일
Hello Walter,
Thanks for your comment.
Refer below edit for actual activity i would like to do.
Edit :
For every TR case, i want output A = "National" or "State" instead of A = 11.
But it is not showing error when A = 11 replaced by A = "National".
How to resolve it.
Walter Roberson
Walter Roberson 2020년 12월 28일
If it is not showing an error when you assign a quoted value to A, then what is there to fix? Just assign the desired strings.
NIKHIL
NIKHIL 2020년 12월 28일
I am not able to assign sting to output A.
Evrytime I am defining output A = "National", it is givinhg error.
Is my representation and implementation of loop in chart is correct ?
Walter Roberson
Walter Roberson 2020년 12월 28일
편집: Walter Roberson 2020년 12월 28일
What is the error you get? And which release are you using?
NIKHIL
NIKHIL 2020년 12월 29일
Error is already posted in question.
Matlab 2018A
You are wanting to do
A = "National"
and you say that you do NOT get an error when you do so. So what is the problem when you do use
A = "National"
?
NIKHIL
NIKHIL 2020년 12월 29일
I am getting error while using string in loop.
When i am assigning A = "National" or any string, it is giving below error.
I want to replace A = 11, by A = "National" but failing to simulate.
Walter Roberson
Walter Roberson 2020년 12월 29일
https://www.mathworks.com/help/stateflow/ug/string-data-in-charts.html

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

답변 (0개)

카테고리

도움말 센터File Exchange에서 Programmatic Model Editing에 대해 자세히 알아보기

질문:

2020년 12월 25일

댓글:

2020년 12월 29일

Community Treasure Hunt

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

Start Hunting!

Translated by