No Output from Repeating Sequence Stair when Running Simulink

조회 수: 6 (최근 30일)
Sonoma Rich
Sonoma Rich 2021년 12월 6일
답변: Abhishek Chakram 2024년 2월 16일
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?

답변 (1개)

Abhishek Chakram
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

카테고리

Help CenterFile Exchange에서 Sources에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by