Simulink : how to make run a switch/case inside a block "Matlab function" ?

11 ビュー (過去 30 日間)
Amaury Bourges
Amaury Bourges 2017 年 4 月 26 日
編集済み: Amaury Bourges 2017 年 4 月 26 日
Hi,
I have a little problem with Simulink concerning a switch/case structure. In a block Matlab Function, I call a function like this one :
function salary = salary_job(job)
job_char = char(job) ; % as Simulink not allows to pass strings between blocks, job is "double"
switch job_char
case 'fireman'
salary = 1000 ;
case 'policeman'
salary = 1200 ;
case 'teacher'
salary = 900 ;
etc...
end
Simulink returns me this error :
"SWITCH expression has indeterminate size."
How to resolve this error without giving the same size to each 'string' ?
Thank you by advance,
Amaury.

回答 (0 件)

カテゴリ

Help Center および File ExchangeModeling についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by