Holding the last value of input signal instead of first value as the zero order hold does
조회 수: 26 (최근 30일)
이전 댓글 표시
I want to hold the last value in the time period instead of first one. how can I do that?? The 'zero order hold ' block holds the first value in the time period for the entire time period.
댓글 수: 4
Jonas
2022년 6월 29일
what exactly is your input signal? can you show an example of input and output you want to have? is this all resitrcted to Simulink or can we use normal Matlab?
답변 (1개)
Gautam
2024년 2월 19일
Hi Shazma,
I understand that you intend to add two signals with different sample times using the Simulink “add” block, such that the output signal is produced at certain time instances.
The desired output can be achieved using a “triggered subsystem”. A triggered subsystem runs the internal blocks whenever a trigger condition is met.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1620968/image.png)
In the image above, the subsystem “Sum” is a triggered subsystem that produces the sum of the two input signals whenever the trigger condition is met by the “Trigger Signal”.
The “Trigger Signal” is a rectangular pulse with a time period of 1 sec and 50% duty cycle.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1620973/image.png)
The “Sum” subsystem produces an output whenever the subsystem encounters a rising edge (transition from the value “0” to value “1”) in the “Trigger Signal” which happens at a time interval of 1 sec.
You can make a triggered subsystem by adding a “Trigger” block from “Simulink/Ports and Subsystems” library as in the image below.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1620978/image.png)
By default, the “trigger type” parameter of the block is set to “rising”.
Below is the output of the model that produces the sum of the two input signals at time intervals of 1 sec.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1620983/image.png)
The plot in red is the output and the plots in yellow and blue are the input signals with sample time of 0.1 sec and 1 sec respectively.
You can find more information about triggered subsystems from the MathWorks Documentation page linked below
Triggers in MATLAB & Simulink:
https://www.mathworks.com/help/releases/R2019b/simulink/slref/trigger.html?searchHighlight=trigger&s_tid=doc_srchtitle
Thank You,
Gautam Murthy
댓글 수: 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!