Why in simulink if you integrate and then derive a signal in the end you don't get the initial signal?

 채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2014년 11월 29일

0 개 추천

If you use these two blocks derivative block and Integrator block you will get the same result, however you can get, for certain cases a difference caused by numerical calculation errors. When the error occur during integration, obviously you will get error after derivation

댓글 수: 2

Vadims
Vadims 2014년 11월 29일
Well in some cases it could be a serious problem when using simulink. If you look at my Example , even a simple sine function has this issue. And since I am currently modeling errors of an inertial navigation system, I would not want to have final results blow up exponential due to Simulink imposed errors. If noone will have a better answer, I will accept your even though I knew that this could be the case. My intention was to address this issue.
Azzi Abdelmalek
Azzi Abdelmalek 2014년 11월 29일
편집: Azzi Abdelmalek 2014년 11월 29일
In model configuration parameters, change the max step size, for example to 0.001, you will get a very small difference (1e-4)

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Matt J
Matt J 2014년 11월 29일

1 개 추천

The derivative only reverses the integral of a continuous function, see

댓글 수: 11

Azzi Abdelmalek
Azzi Abdelmalek 2014년 11월 29일
Simulink provides continuous derivation, obviously, it's an approximation based on numerical solution
Matt J
Matt J 2014년 11월 29일
편집: Matt J 2014년 11월 29일
Not sure what "continuous derivation" means.
I'm not sure it matters, though. If the continuous integral of a function is not differentiable at a certain point, the discrete approximation of a derivative there will give arbitrary results.
Matt J
Matt J 2014년 11월 29일
편집: Matt J 2014년 11월 29일
For example, the integral of a step function (i.e., a ramp) is not differentiable at t=0. Therefore, different numerical approximations of the derivative there will give different results at that point. A right handed derivative will give the original value back, assuming t=0 is exactly sampled, but centered derivatives or other types will give something else.
Azzi Abdelmalek
Azzi Abdelmalek 2014년 11월 29일
Check it with simulink: derivative block and Integrator block : you will get the original signal
Matt J
Matt J 2014년 11월 29일
편집: Matt J 2014년 11월 29일
Don't have Simulink. But if it's true, it simply implies that the derivative block does right handed derivatives.
Vadims
Vadims 2014년 11월 29일
=< I am well aware of limitations when using derivatives and obviously I am using a continuous function. I have tried using sine and afterwards subtract original signal from ending one. The result is a sine function that also has a constant shift.
Azzi Abdelmalek
Azzi Abdelmalek 2014년 11월 29일
You mean a slight shift
Matt J
Matt J 2014년 11월 29일
편집: Matt J 2014년 11월 29일
obviously I am using a continuous function.
How was it obvious? You just told us that now.
Anyway, if it is a slight shift, as Azzi proposes, I suspect it's because the differentiation step is using diff() internally, without any extrapolation. That's why the '1' is not recovered when diff() is applied in the example below.
>> x=1:5
x =
1 2 3 4 5
>> y=cumsum(x) %numerical integration
y =
1 3 6 10 15
>> z=diff(y) %numerical differentiation
z =
2 3 4 5
Extrapolating the beginning of the signal with zeros is a solution for this,
>> z2=diff([0,y])
z2 =
1 2 3 4 5
It could also be because of mismatch between the integral approximation and the derivative approximation. If trapezoidal integration is used instead of cumsum() above, you get a mismatch when using diff:
>> y2=cumtrapz(x)
y2 =
0 1.5000 4.0000 7.5000 12.0000
>> z3=diff(y2)
z3 =
1.5000 2.5000 3.5000 4.5000
Vadims
Vadims 2014년 11월 29일
Omg, can you read? I told, I was using simulink. And who in his right mind would ask about differenciating step values. Here you can see, that even sine has this problem. Note that original amplitude was 1 therefore difference with an aplitude of 0.06 and constant shift of -0.06 in not acceptable.
Matt J
Matt J 2014년 11월 29일
편집: Matt J 2014년 11월 29일
Omg, can you read? I told, I was using simulink.
Yes, I didn't fail to see that we were talking about simulink. The manipulations I did at the command line are examples to show the issue. They are likely similar to what simulink is doing internally, and with similar issues.
And who in his right mind would ask about differenciating step values.
I don't know you and I don't know if you're in your right mind... But my remarks and examples of differentiator/integrator mismatch would apply to sines as well.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Modeling에 대해 자세히 알아보기

태그

질문:

2014년 11월 29일

편집:

2014년 11월 29일

Community Treasure Hunt

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

Start Hunting!

Translated by