Derivative after integration issue.
古いコメントを表示
Why in simulink if you integrate and then derive a signal in the end you don't get the initial signal?
採用された回答
その他の回答 (1 件)
Matt J
2014 年 11 月 29 日
1 投票
The derivative only reverses the integral of a continuous function, see
11 件のコメント
Azzi Abdelmalek
2014 年 11 月 29 日
Simulink provides continuous derivation, obviously, it's an approximation based on numerical solution
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
2014 年 11 月 29 日
Vadims
2014 年 11 月 29 日
Azzi Abdelmalek
2014 年 11 月 29 日
You mean a slight shift
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
Matt J
2014 年 11 月 29 日
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
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 についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!