How to hold maximum value of one signal for maximum value in seconds?

조회 수: 18 (최근 30일)
Hasan Kaan Tuna
Hasan Kaan Tuna 2023년 12월 6일
답변: Tushar 2023년 12월 12일
Hi all,
I have a signal that indicates time difference between sequences. That value is calculated for few samples, then evalues back to zero. I'd like to catch those calculated sequence changing times and implement in other calculations. I can't use zero order hold block since I have fixed sample time for my Simulink model. Do you have any other suggestions?
Thank you.
  댓글 수: 6
Sam Chak
Sam Chak 2023년 12월 6일
I think tracking can be done by comparing the current value with the previously sampled value and then evaluating which one is greater. If the current value is greater, then take it as and set it to hold for a duration equivalent to its value.
However, I'm unsure of how you want the algorithm to work. After holding the value for a period of time, what specific actions do you want the algorithm to take next? Can you sketch the task flow diagram and update your question? This will allow other users to gain a better understanding of your problem without scrolling down to read other comments.
Sam Chak
Sam Chak 2023년 12월 6일
@Hasan Kaan Tuna, can you take this cosine signal as an example?
n = 0:0.5:15;
y = cos(2*pi*n/10);
stem(n, y), grid on
ylim([-1.5 1.5])
xlabel t, ylabel y

댓글을 달려면 로그인하십시오.

채택된 답변

Tushar
Tushar 2023년 12월 12일
Hi Hasan,
I understand that you want to hold the maximum value of a signal for “a duration of the maximum value” in seconds.
Firstly, to achieve this, you would need to find the local maxima of the signal in Simulink. You can use the MinMax Running Resettable block for this purpose, which outputs the minimum or maximum of all past inputsu’. Have a look at the below documentation, it also includes an example displaying how to use the MinMax Running Resettable block to calculate the running minimum value.
After finding the local maxima, you need to hold that value of the signal when the local maxima occur. I found a similar MATLAB Answer, which is linked below. It recommends using an Enabled Subsystem to hold the value of a signal.
Alternatively, if you access to the DSP System Toolbox, you can use the Sample and Hold a Signal” block which samples an input signal when a trigger event occurs and holds the value until the next trigger. I have provided the documentation link for this block below.
I hope these resources are useful.
Best,
Tushar

추가 답변 (0개)

카테고리

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

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by