Calculating the difference between a vector and time
1 次查看(过去 30 天)
显示 更早的评论
I'm looking for a way to get this loop to work, basically I need to calculate the difference in a 3x1 vector divide by the difference in time. Does anyone have any suggestion?
t = 2000
n= 0;
for ind = 0:1:t
n= n+ind;
S(n) = (diff(x( don't know how to input the value here )))./diff(t(ind)); %x is a three element vector
end
5 个评论
Star Strider
2019-5-5
If you are ‘padding’ ‘A’ with an initial 0, you need to tell MATLAB.
MATLAB does many things well, although it is sadly deficient when it comes to mind-reading.
Try this:
A = [1 1 2 3];
dA = diff([0 A])
producing:
dA =
1 0 1 1
NOTE — You need to do similar ‘padding’ for your time vector.
回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Symbolic Math Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!