フィルターのクリア

Why is the derivative of a function or signal one sample shorter that the orignal?

11 ビュー (過去 30 日間)
Hi All
taking the derivative of y=x.^2 using diff(y) , between 0 and 100 gives a signal with one less Sample, meaning instead of length of 101, it is 100 samples. so every derivative, it will get one sample shorter and if I have to integrate again, it will need those samples again maybe ? what should I do ?

採用された回答

Star Strider
Star Strider 2020 年 4 月 11 日
Use the gradient function to calculate the numerical derivatives. The output will be the same length as the input. (It is also more accurate in that respect.) The function assumes regularly-sampled data, however if the sampling intervals are not constant, a work-around for that is:
dydx = gradient(y) ./ gradient(x);
.
  2 件のコメント
farzad
farzad 2020 年 4 月 11 日
As Always ,Thank you So much !
Star Strider
Star Strider 2020 年 4 月 11 日
As always, my pleasure!

サインインしてコメントする。

その他の回答 (1 件)

Cris LaPierre
Cris LaPierre 2020 年 4 月 11 日
diff is taking the difference between adjacent data points. Because the difference is between two points, this causes the result to be one data point shorter.
For a simple array x=[3 4 5], diff(x)=[4-3 5-4] = [1 1].
  2 件のコメント
farzad
farzad 2020 年 4 月 11 日
I see, So : How would you handle it ? should the derivative of a signal be shorter always ?
farzad
farzad 2020 年 4 月 11 日
If the signal is over time, then it will be somehow meaningless or meaningfull to have a shorter signal for acceleration or velocity of that signal ?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeDescriptive Statistics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by