From: Praetorian on
On Jun 4, 11:47 am, "Steve Amphlett" <Firstname.Lastn...(a)Where-I-
Work.com> wrote:
> Praetorian <ashish.sadanan...(a)gmail.com> wrote in message <71157d0f-7ca1-46c1-a583-67a30832c...(a)q36g2000prg.googlegroups.com>...
> > > If anybody cares, here are my findings:
>
> > > The macro ssGetSampleTime() cannot reliably be used to get the block sample rate. Its return value depends on the solver type, whether the block is inheriting its sample rate and whether the block is in a triggered subsystem. This is documented nowhere in the Matlab help system (I opened a support enquiry with TMW about this). Experimentation showed that the macro returns:
>
> > > If in a triggered subsystem, -1.
> > > If in a block inheriting timestep, running with a variable solver: 0.
> > > If in a block with fixed timestep, running with a variable solver: the fixed timestep.
> > > If in any inheriting block with a fixed solver, the inherited timestep actually used.
>
> > > So there are 4 distinct behaviours for this macro. But at least it seems (though not verified by either TMW or their docs) that any positive value is ok to use as the block sample time.
>
> > Steve,
> > I've also tinkered with this a while back (sorry, I missed your
> > earlier posts on the subject). I believe TMW also uses the offset time
> > to convey some information. There is a macro named
> > ssSampleAndOffsetAreTriggered and I think it just checks whether both
> > sample and offset times are set to -1.
>
> > Also, other cases where ssGetSampleTime cannot be used reliably are:
> > If your S-Function uses port based sample times, use
> > ssGetIn(Out)putPortSampleTime in that case.
> > If your S-Function has inputs / outputs set to different sample times;
> > not quite sure what to use in this case but I believe to implement
> > such an S-Function you need to have port based sample times, so the
> > first case would apply.
>
> > Regards,
> > Ashish.
>
> When ssGetSampleTime() returns zero (variable solver, inherited block sample, quite a common combination), all I think to do was to use:
>
> ssGetT(S)-ssGetTimeOfLastOutput(S)
>
> even though ssGetTimeOfLastOutput(S) is not documented.  Using non-docs leaves me a bit queasy.
>
> - Steve

Thanks for that tip, I didn't know about the ssGetTimeOfLastOutput()
macro. But I'm like you, I'm uneasy using undocumented API too.
First  |  Prev  | 
Pages: 1 2
Prev: ifft of fft scaling
Next: create a sine wave