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

11 visualizaciones (últimos 30 días)
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 comentarios
Sam Chak
Sam Chak el 6 de Dic. de 2023
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 el 6 de Dic. de 2023
@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

Iniciar sesión para comentar.

Respuesta aceptada

Tushar
Tushar el 12 de Dic. de 2023
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

Más respuestas (0)

Productos


Versión

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by