Is it possible to pass a parameter which represents the "sampleTime" at a 2-Level S-function?
조회 수: 2 (최근 30일)
이전 댓글 표시
Is it possible to pass the sampleTime value as a parameter or an input into a S-function and to use this this value further in the S-function Outputs algorithm?
At the moment I programmed it in the following way: block.SampleTimes = [1e-3 0],
but I would like to have it like this: block.SampleTimes = [s_func_sample_time 0],
in order to specify the sample time somehow from outside of the S-function and to pass this value e.g. via the s_func_sample_time variable. Does there exist a possibility to do this either via the S-function parameter mask (block.NumDialogPrms) or via the S-function inputs (block.InputPort) or in any other way?
My aim is to use this parameter (s_func_sample_time value) further in the S-function Outputs function. E.g. in order to realize a discrete PI-controller. For the I-part it is necessary to know the sample time in order to integrate over the corret time interval. This sample time would be stored in the s_func_sample_time variable and I could use it in the Outputs algorithm.
댓글 수: 1
채택된 답변
Guy Rouleau
2012년 7월 5일
IT should be possible to do something like:
block.SampleTimes = [block.DialogPrm(1).data 0];
to set the sample from a parameter.
It is not possible to set a discrete sample time of the s-function using a signal. For that, you would need to create a variable sample time s-function, because the value of a signal can change.
In your output function, you should be able to read block.SampleTimes and use the value.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Block and Blockset Authoring에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!