|
Steven Evans wrote:
>
>
> I tried both you ideas by putting the following in the mdlOutputs
> function.
>
> time_T time = ssGetT(S);
> time_T dt = time - m_lastTimeStep;
>
> m_lastTimeStep = time;
> ssPrintf("Task 0 sample hit in %s time = %g dt=%g
> stepSize=%g\n", ssGetPath(S),time, dt, S->mdlInfo->stepSize);
>
>
> this gave the following result.
>
> Task 0 sample hit in A320model/J2 Active time = 0.1 dt=0.00453889
> stepSize=0
> Task 0 sample hit in A320model/J2 Active time = 0.1 dt=0 stepSize=0
> Task 0 sample hit in A320model/J2 Active time = 0.1 dt=0 stepSize=0
> Task 0 sample hit in A320model/J2 Active time = 0.113274
> dt=0.0132738
> stepSize=0
> Task 0 sample hit in A320model/J2 Active time = 0.119911
> dt=0.00663691 stepSize=0
> Task 0 sample hit in A320model/J2 Active time = 0.153095
> dt=0.0331845
> stepSize=0
> Task 0 sample hit in A320model/J2 Active time = 0.158995
> dt=0.00589947 stepSize=0
> Task 0 sample hit in A320model/J2 Active time = 0.166369
> dt=0.00737434 stepSize=0
> Task 0 sample hit in A320model/J2 Active time = 0.166369 dt=0
> stepSize=0
> Task 0 sample hit in A320model/J2 Active time = 0.166369 dt=0
> stepSize=0
>
> As you will see the step size was always 0 and the output was
> called
> upto 3 times with the same time giving a dt of zero.
>
> What have I missed?
>
> riccardo wrote:
>>
>>
>> Steven Evans wrote:
>>>
>>>
>>> Hi,
>>> Can some one help I need to find t, dt in the mdlOutputs
> function
>>> of an s-block. I have got t using ssGetT(S). Now I need to
> find
>> dt
>>> (the differance between the current time as the time last
> use).
>>>
>>> The S-block is set to use [INHERITED_SAMPLE_TIME, 0.0].
>>
>> Steve,
>> if you have a look in Simstruct.h there should be an entry for
> the
>> current integration time step.
>> Another way to get almost the same result is to define a state
>> variable to store the time the Output function has been last
> called
>> and take the difference to the current one before updating it.
>> HTH
>> riccardo
Steve,
you're running a continuous-time simulation and your print outs will
depend on the integrator used: if I remember correctly mdlOutputs is
called both at minor and major time steps, and you probably want
major steps only.
I believe - again if I remember correctly - that you should get hold
of the Simulink model's S structure if you want to print out the
stepSize, as your s-function doesn't define one.
HTH
Riccardo
|