The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Counting time steps in Simulink
Replies: 2   Last Post: Sep 13, 2000 9:42 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]

Posts: 22
Registered: 12/7/04
Re: Counting time steps in Simulink
Posted: Sep 13, 2000 5:06 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On Wed, 13 Sep 2000, Stefan Ahlman wrote:

> Hi!
> I have a time-discrete Simulink model with a fixed step size of 1. For
> one signal I would like a routine to count the number of time steps
> elapsed from when the signal reaches below a certain limit to when the
> signal reach the limit again. When the signal exceeds the limit the
> counter should be reset to zero. I think a S-function should do the
> trick, but unfortunately I find the syntax of S-functions to be a bit
> complicated. The Ramp-source doesn't work because it only counts from
> the beginning of the simulation.
> Can anyone help me with this problem?

I have another idea :) It's much simpler than an S-function, and I tested
it this time, first.

I'm not sure of the best way to convey this through a newsgroup, so I'll
describe what it does, then I'll try to describe the connections.

The output of your relational comparison is either a 1 or a 0. If you add
up the successive outputs you'll get a ramp that levels off everytime your
signal is outside the bounds. If you multiply that ramp by the output of
the relational block, it will reset itself to zero when your signal is
outside the bounds, but it won't be affected when the comparison is true.

Feed the output of the relational block into a product block. The other
input to the product block is from a sum block. One imput to the sum
block is the output from the same relational block. Feed the output from
the product block into a memory block, and feed that into the sum block.

I can attach a sample file if you still need it. Let me know.

+----------------------------+ Want to know the secret to riding a bike
| | from Fairbanks to Anchorage?
| Greg Anderson | 1. Push down with left foot.
| Rogue Squadron - Rogue 31 | 2. Push down with right foot.
| | 3. Repeat.
| | 4. Stop when you reach Anchorage.
| AIM - Aranthon |
| | I know it seems pretty simple, but it
| | worked for me. AAVR 1, 8/20-8/26, 2000
+----------------------------+ Want to help me wipe out AIDS? Ask me how!

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.