# Derivative of vector wrt time vector

34 ビュー (過去 30 日間)
Jerry 2012 年 8 月 8 日
コメント済み: Rusty 2015 年 1 月 17 日
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 件のコメント-1 件の古いコメントを表示-1 件の古いコメントを非表示
Rusty 2015 年 1 月 17 日
Hi, I have made a program for you. Do you want the answer?

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

### 採用された回答

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 件のコメント3 件の古いコメントを表示3 件の古いコメントを非表示
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 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.

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

### カテゴリ

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

### Community Treasure Hunt

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

Start Hunting!

Translated by