Hello, I have a little doubt, someone could tell me how to get the maximum value of the output (curve shown in blue on the oscilloscope)
Thank you so much.

 Réponse acceptée

Ameer Hamza
Ameer Hamza le 7 Nov 2020
Modifié(e) : Ameer Hamza le 7 Nov 2020

1 vote

max block is not suitable for saving the maximum value. See the example in the attached file (Saved in R2020b).

4 commentaires

Wow, thank you so much! And maybe you know how can I implement this function in another block?
function Ts = fnc(data,t)
idx = abs(data-data(end)) < 0.05 * data(end);
idx = find(idx == 1);
Ts = t(idx(1));
end
Being the variable data the information obtained at the output and t the time vector that the test is performed.
What the function should do is to give the first instant of time that enters within a margin of +-5% of the value of the output
data(end) will not be available until simulation is completed. You can not use it in the test. Note that Simulink will not input a vector 'data'. At each iteration, 'data' will be a scalar number. Since you already now that data(end) is 1, so directly use it. Something like this
function Ts = fnc(data,t)
persistent flag
persistent T
if isempty(flag)
flag = 1;
T = 0;
end
if flag && (abs(data-1) < 0.05 * 1)
flag = false;
T = t;
end
Ts = T;
However, it will note the time when the output is rising, not when it is settling.
Alejandro Fernández
Alejandro Fernández le 7 Nov 2020
Modifié(e) : Alejandro Fernández le 7 Nov 2020
And where can I get the t-value of what I have in simulink? I tried with a Clock but I don't know if it's correct..
Ameer Hamza
Ameer Hamza le 7 Nov 2020
No, clock is the correct block to use here. I should be giving the correct time values.

Connectez-vous pour commenter.

Plus de réponses (0)

Produits

Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by