Derivative of vector wrt time vector

63 views (last 30 days)
Jerry
Jerry on 8 Aug 2012
Commented: Rusty on 17 Jan 2015
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.
  1 Comment
Rusty
Rusty on 17 Jan 2015
Hi, I have made a program for you. Do you want the answer?

Sign in to comment.

Accepted Answer

Kevin Claytor
Kevin Claytor on 8 Aug 2012
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 Comments
Jerry
Jerry on 12 Aug 2012
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 on 12 Aug 2012
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.

Sign in to comment.

More Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!