How can I determine the time t when a specific value y is reached in SIMULINK?

Hi everyone,
I'm working on a simulation on SIMULINK which outputs me a value y(t).
I now want to know at what time y(t) reaches a specific value y_1.
So I need to determine t(y_1) = t_1 and somehow display it in SIMULINK?
Also I want to used that value t_1 for further calculations.
Is there any block that I can use for that?
Best regards
Enea

 Accepted Answer

There are multiple ways of doing this. One is to attach the source block "clock" to a triggered subsystem which contains just a connection between in and out. The trigger input is fed by a comparator which checks for y(t) = y_1.
The triggered block now takes over the simulation time input to its output only in case the comparator triggers.

12 Comments

Hi there,
thank you very much for your answer!
That worked perfectly!
One more question. I now have as a output of the triggered subystem a stepfunction that reaches t_1 at t_1.
How can I now convert the final value (t_1) of that output into a normal constant block?
Hm, would help if you could describe in more detail for what exactly you want to use that signal. It actually is constant - after t_1.
Okay, so the problem I have now is the following.
I basically have to equations to solve with SIMULINK.
First I want to solve equation 1. When equation 1 is solved I want to determine the time t_1 when the solution of euqation 1 reaches y_1. This worked so far.
Now I want to use t_1 as a parameter in the equation 2.
I somehow have to tell SIMULINK to first solve equation 1 and after having solved that it should start solving equation 2.
If you insist on having a strict order and equation 2 must not run before equation 1 is done, you could e.g. do this:
Put equation 2 in an enabled subsystem and attach a comparator which checks for t_1 > 0 to the en input.
But, what's the issue with letting equation 2 run continuously and just rejecting all results before the output of your triggered sybsystem changed to t_1?
Hmmm, alright.
The thing is, equation 2 needs the whole output (so y(t)) of equation 1 and also the value t_1 from the begining of the calculation.
When I compute equation 1 and 2 simuntaniouly and continuously, the value t_1 is not available for the equation 2 from the beginning on.
In the picutres attached you can see the output of the triggered subsystem which is part of the equation 1. What I want is to used that value (0.65) as a constant in equation 2.
So I need to first calculate eqauation 1 which gives me the solution y(t) and also t_1.
Then I need to compute equation 2 with these to inputes (where y(t) is a function of time and t_1 is a constant).
Thank you so much for you help!!!
Does eq2 need the eq1 output starting at t=0 or at t=t_1?
The only solution for option 1 - I could imagine right away - is to duplicate eq1 with the argument t'=t-t_1 and put eq1' and eq2 (or eq2') inside the enabled subsystem. Thus, both would deliver the results as starting from zero and eq2 input t_1 woud be available, already.
Yes, eqation 2 needs the output from equation 1 startion from t=0.
Alright, yes that sounds like a solution. I will try that!
Thank you very much for your help!
I can't figure out how to change the argument to t' = t - t_1.
How would you do that?
I'm puzzled. You wrote eq1 is a y(t) function so I assumed one input is t, which could be easily changed to t-t_1. In case your eq is implicitly depending on t in terms of simulation time only, you don't have to change anything. Just put eq1 and eq2 in the enabled subsystem. Since enable is 1 after t_1 the internal equations start with the internal start time of zero, which is delayed by t_1 with respect to the overall simulation time.
Or are we talking at cross-purposes?
Sorry for that.
I was able to solve it. As you said I put eq1' and eq2 into a enabled subsystem.
The subsystem is enabled as soon as t_1 is reached (calculated by eq1).
The subsystem's input is t_1.
This way, inside the subsystem eq1' is computed feeding its output to eq2 and and t_1 is obtained by eq1.
Thanks for your help!
Perfect! This is what I tried to explain. Good luck, furthermore.

Sign in to comment.

More Answers (0)

Categories

Find more on Modeling in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!