No Output from Repeating Sequence Stair when Running Simulink
5 次查看(过去 30 天)
显示 更早的评论
When running a simulation on Simulink where the Start Time is not zero, the output from a Repeating Sequence Stair block or other similar sources is "no data yet". The block sample time is different from the default sample time. The issue has to do with the block sample time offset which I had to set as follows to make it work:
[scanPeriod ceil(rem(str2double(get_param('LineScanSimulation','StartTime')),scanPeriod)/samplingTime)*samplingTime]
Is there an easier way to set the time offset such that the output starts when the simulation Start Time is set to a value other than zero?
0 个评论
回答(1 个)
Abhishek Chakram
2024-2-16
Hi Sonoma Rich,
When you are working with blocks like the Repeating Sequence Stair in Simulink, and you want them to output data starting at a simulation start time other than zero, you indeed need to adjust the sample time offset to align with the simulation start time. Here is another way for the same:
% Get the simulation start time
startTime = str2double(get_param('LineScanSimulation','StartTime'));
% Calculate the offset as the nearest lower multiple of the sample time
offsetTime = floor(startTime / scanPeriod) * scanPeriod;
% Set the sample time and offset in the block
set_param('YourBlockPath', 'SampleTime', num2str(scanPeriod), 'OffsetTime', num2str(offsetTime));
Replace “YourBlockPath” with the actual path to your Repeating Sequence Stair block.
Best Regards,
Abhishek Chakram
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Sources 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!