Derivative of vector wrt time vector

45 次查看(过去 30 天)
if i have a vector x=[0 6 7 7.....] and this x is measure with respect to a time vector then how can we find the derivative like dx/dt like the simulink block has the drivative, which computes with respect to simulation time but what can be done i case of MATLAB how this time vector can be differentiated with the x vector becasue both contain values. Any idea will be appreciated.

采纳的回答

Kevin Claytor
Kevin Claytor 2012-8-8
A simple brute force numerical derivative would be find the change in x and divide by the change in t;
dx = x(2:end) - x(1:end-1);
dt = t(2:end) - t(1:end-1);
v = dx./dt
  5 个评论
Jerry
Jerry 2012-8-12
diff gives the same output but my problem is my length is decreasing, I must agree with Greg here but how can we have a way that after applying diff or gradient the size remains same to the original vector since due to diff it become n-1 ,by mean of interpolation or what how shud v keep it to the original size? I have posted another question for this I hope you can help me on this since i developed the whole code myself by taking constant help from you guys.
Jerry
Jerry 2012-8-12
Greg Thanks i think i got your point here... for initial and boundary conditions, ok can if i have an array
X=[ 0.1000 0.0844 0.0434 -0.0090 -0.0559 -0.0831 -0.0832 -0.0574 -0.0152 0.029] Which shows the position and time array with respect to that position is T= [0 0.5000 1.0000 1.5000 2.0000 2.5000 3.0000 3.5000 4.0000 4.5000]
can i like take time 0 as initial value and the last value as boundary condition.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Mathematics 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by