differentiating twice in simulink

I tried to use derivative block twice where the input is a sine wave and it does not give the output I expected. Why is that and how can I make an system that differentiate the input signal twice? I would like to create a feedforward controller that differentiate twice the input signal by using a differentiator block. Can I get some suggestions on how to do that ? In the second picture I attached, the input signal is supposed to be desired theta but since double derivative block does not work in simulink, I had to find double derivative of the input analytically first and then integrate twice to get the input again.

1 Comment

I seldom use the derivative block. If you already know the theta function (sine wave) beforehand, then you can definitely obtain the analytical 2nd-order derivative of the sine wave. Is this true?

Sign in to comment.

 Accepted Answer

Angelo Yeo
Angelo Yeo on 6 Nov 2023
Edited: Angelo Yeo on 6 Nov 2023
I need your model for further investigation because the issue is not reproducible in my end. However, I believe the fact that the initial output value for the Derivative block is always 0 should have something to do with your issue (see here)
If you closely look at the output of first derivative, the initial output is set to be 0. This is a designed behavior. This will lead to sharp slope of the first derivative at its initial point, which leads to a spike in the second derivative.

6 Comments

I submitted my model and the problem Im trying to solve.
I am trying to make a feedforward controller system which takes in desired theta value and differentiate it twice and then multiply with other constants to give back the tau value.
I hope to make desired theta value as input of block system to complete my system for any input. Otherwise, I have to analytically find double derivative and use integral blocks to work.
I would really be helpful if you could help me solve it. Im stuck at this stage and was lost for 2weeks now since I cant find the answer to it.
Thank you for giving your time and consideration
What's the core issue? I don't know your parameters and I set them with the following script.
m = 1; g = 9.8; M = 1; r_measured = 1; b = 1; r = 1;
I also found that your step size is too large (0.6). Even though it is automatically set, it may worth to making it smaller, like 0.01. This makes the Scope3 result in like below.
I don't know what your core issue is only with the problem statement. I hope this approach can give you a hint.
Im sorry that I lack a lot. But how can I change step size in simulink?
Please check out the doc below. You can go to Model Configuration > Solver and set the step size.
https://www.mathworks.com/help/simulink/gui/fixedstepsizefundamentalsampletime.html
thank you very much.
let me add only one more question .
here as you can see in my picture, the signal I got from two consecutive derivate block and the signal I found analytically is different in a way that the signal from derivative block has initial value of 0. How can I add some initial value to get the same result as the signal I analytically calculated?
Well, you can use the IC block in order to set the initial condition no matter what the original initial condition is. However setting the initial condition does not guarantee the exact result as analytic solution. Be aware that Simulink runs based on numerical calculations.

Sign in to comment.

More Answers (0)

Categories

Find more on Prepare Model Inputs and Outputs in Help Center and File Exchange

Products

Release

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!