How to access Fundamental Sample Time value within a simulink model
조회 수: 34 (최근 30일)
이전 댓글 표시
I have a model will run fixed step discrete. Some of the subsystems I must use require the value of the fundamental step time as an input.
The quick version is, of course, to use a constant as an input and set it equal to the value of the fundamental sample time that's input in the configuration parameters.
And, of course, this method is an invitation to subtle bugs when the configuration parameter is changed but someone forgets to change one of the constant blocks to match.
So - is there a way to simply pull in the value that's been set within the configuration parameters?
Thanks.
댓글 수: 0
채택된 답변
Vishal Rane
2012년 11월 28일
편집: Vishal Rane
2012년 11월 28일
SampleTime = get_param(MdlName,'FixedStep')
gives you the Fixed-step size (fundamental sample time) as specified in Simulation > Configuration Parameters.
You could also use this inside a model callback (startfcn) to ensure that value is present in the base when the model is simulated.
댓글 수: 4
Dana Schwanke
2022년 6월 27일
This doesn't seem to work for Stateflow. I am trying to access the Stateflow chart's discrete Sample Time for part of a state's during: section. Any way I can do this?
Leonardo
2023년 3월 27일
Hi Dana!
I am having the same issue as you, could you find a way to do what you are asking here?
추가 답변 (1개)
Babak
2012년 11월 27일
In Simulink Library Browser, go to the Simulink, Signal Attributes, section. There is a block called Weighted Sample Time.
That's what you can use to multiply any signal with it to get Ts.
댓글 수: 2
Babak
2012년 11월 28일
Simulink is based on blocks and signals. I don't think there is any pre-defined, and system set up variable like Ts that you can just simply write it anywhere in any block and use it that way. I think the only solution is what you said, just connecting a unit step or 1 constant source to the Weighted sample block.
참고 항목
카테고리
Help Center 및 File Exchange에서 Interactive Model Editing에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!