How can i find the derivative of a vector?
98 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Emmanouil Poulakis
il 27 Apr 2015
Commentato: Emmanouil Poulakis
il 27 Apr 2015
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.
0 Commenti
Risposta accettata
pfb
il 27 Apr 2015
Modificato: pfb
il 27 Apr 2015
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.
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!