1
$\begingroup$

I'm trying to implement a smoothed step function in Simulink.

I tried to put a filter after the step function: enter image description here

The result is not what I wanted. How can I smooth even around 1 the function? My deal is to not have a dramatic change on behavior.

A possibile idea is to have something like: enter image description here

Thanks in advance

$\endgroup$
3
  • $\begingroup$ Welcome to Robotics, marcck. Could you sketch what you want the curve to look like? It sounds almost like you're really after a ramp input and not a step input, or a filtered ramp that would make an S-curve. I'm not sure what to recommend here because it's not clear what your goal is. $\endgroup$
    – Chuck
    Oct 16, 2022 at 23:35
  • $\begingroup$ I edited the question. $\endgroup$
    – marcck
    Oct 17, 2022 at 13:35
  • $\begingroup$ I don't think the desired function you're looking for is a step function. Also, the smoothness word here may not be the right choice but truly they are both smooth. $\endgroup$
    – CroCo
    Oct 17, 2022 at 19:42

2 Answers 2

3
$\begingroup$

There are a variety of functions that can give you an "S" curve like you want. Check out the Sigmoid function.

I usually use something like this:

$f(x) = \frac{x}{\sqrt{1+x^2}}$

And it can be adjusted for varying amounts of "steepness".

$f(x) = \frac{x}{\left(1 + |x|^{k}\right)^{1/k}}$

Here is one in the range you specified:

$f(x) = \frac{1}{(1.0 + e^{-10x+5)}}$

$\endgroup$
2
  • $\begingroup$ I like the formulas :D My answer's the lazy way :P $\endgroup$
    – Chuck
    Oct 17, 2022 at 20:26
  • $\begingroup$ @Chuck your answer is beating around the bush :) $\endgroup$
    – CroCo
    Oct 18, 2022 at 10:16
1
$\begingroup$

So you could use the ramp block, but that only has a turn-on time and a slope; there's no limiting it once it's turned on.

What I prefer to use instead is the repeating sequence block, which lets you define an arbitrary output/time pairs.

If your simulation runs for 10 seconds, and you want a ramp that outputs zero at t=0, one at t=1, and holds that value for the full simulation, then you would give time values of:

[0, 1, 10]

and you would give output values of:

[0, 1, 1]

which would build you that ramp. Then, if you want to smooth the corners on that ramp, you can pass the output through the same filter you used for the step input.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.