How can i find the derivative of a vector?

147 ビュー (過去 30 日間)
Emmanouil Poulakis
Emmanouil Poulakis 2015 年 4 月 27 日
コメント済み: Emmanouil Poulakis 2015 年 4 月 27 日
I have a vector 1x80. If i put x(1,80) and y (the values of the vector from 1 to 80), i have a plot. I do not know the function which describes the plot. I want to plot the derivatives of the unknown fuction.

採用された回答

pfb
pfb 2015 年 4 月 27 日
編集済み: pfb 2015 年 4 月 27 日
You can do that approximately.
% this is the "finite difference" derivative. Note it is one element shorter than y and x
yd = diff(y)./diff(x);
% this is to assign yd an abscissa midway between two subsequent x
xd = (x(2:end)+x(1:(end-1)))/2;
% this should be a rough plot of your derivative
plot(xd,yd)
Of course the reliability of the above procedure depends on the thickness of your grid x as well as on the properties of y.
You could perhaps do a slightly (cosmetically) better job by interpolating your data using interp1.
  1 件のコメント
Emmanouil Poulakis
Emmanouil Poulakis 2015 年 4 月 27 日
Thank you!I think this is helpful for me.When you say to interpolate my data, you mean to find a function which desribes the data?Is it easy to give me an example how to do this..

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by