"duration" function in stateflow using fixed-point datatype for time
4 次查看(过去 30 天)
显示 更早的评论
I created an mpt.parameter for a time variable. Since time is in ms, I assigned data type as fixdt(0,16,0.001,0)
time_s = mpt.Parameter;
time_s.CoderInfo.Alias = 'Ts';
time_s.Description = 'Time in ms';
time_s.DataType = 'fixdt(0,16,0.001,0)';
time_s.Unit = 's';
time_s.Value = 0.5;
Now in one of my stateflow transition between states, I need to use this time variable. i.e: [duration(t > 20) > time_s]
Matlab thowrs error as below:
In fi > non-fi, or non-fi > fi, the non-fi must be a constant. Transition '[durat...time_s]'"duration(t > 20) > time_s"
Component:Stateflow | Category:Coder error
Error while generating code for chart Chart.
ps: I need fixdt(0,16,0.001,0) since I need to generate fixed point code and cannot afford using single or double or any Integer type.
Is there a workaround for this? Thanks in advance

0 个评论
回答(1 个)
stozaki
2020-1-25
编辑:stozaki
2020-1-25
't' is a reserved word of the double data type. Therefore, you cannot set attributes such as data type.
I thought that using the after function was one of the workarounds. I have attached a sample model.
4 个评论
stozaki
2020-1-30
Temporal Logic,
When using Event-Based (tick/CLK): Positive integer
When using Absolute-Time (sec/msec): It is just a positive number, that is, a double type.
So, My model uses Event-Based Temporal Logic. This is a workaround.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Simulink Functions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!