How can I subtract every element in an array (including the first element) from the first element of the same array
4 次查看(过去 30 天)
显示 更早的评论
Hi guys,
I am calculating the Bodys CoM and I need to find the Jump Height from it. To do so, I need to subtract every element in the array of the Bodys CoM from the first element of the array (which is basically like the starting point). Any ideas how I can do this? Any help would be appreciated.
0 个评论
采纳的回答
Voss
2024-3-25
v = 3:4:15 % an array
v-v(1) % subtracting the first element from each element
v(1)-v % subtracting each element from the first element
3 个评论
Voss
2024-3-25
Because of the extra '1' in the disp call.
Body_CoM = [13 13.608 13.3];
JumpHeight = Body_CoM - Body_CoM(1);
biggestJump = max(JumpHeight)
% extra '1':
disp(['Maximum Jump height 1',num2str(biggestJump),' meters'])
% no extra '1':
disp(['Maximum Jump height ',num2str(biggestJump),' meters'])
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Multidimensional Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!