0

I have a Simulink model and I want to translate the whole model to a python code. Now I am struggling with the translation of a block named "derivative". The documentation regarding this block is available in Click here.

I have used the following code to take the derivative of my input signal:

derivative = np.gradient(percentage, time)

where the np is the Numpy library. The picture shows the input signal. And after applying the derivative I was expecting to get this output which I got this one: Output!.

2
  • 2
    The black scope image is misleading, note your y axis scale starts at 4x10^12!! You should do a "pen and paper" sense check here, the derivative (gradient) of your red input signal is some positive constant, then zero, then some negative constate - exactly what you see in the blue output. You probably have a bad initial condition and large step size in your Simulink model which is causing the huge initial value, which is hiding the small values on the scope (which you would see are probably correct if you zoom in on the y axis)
    – Wolfie
    Commented Sep 12, 2023 at 9:16
  • 1
    @Wolfie Thanks a lot. I zoomed to it and found that the result are nearly same :)
    – Soheil yns
    Commented Sep 12, 2023 at 11:03

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.