How can I subtract every element in an array (including the first element) from the first element of the same array

3 views (last 30 days)
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.

Accepted Answer

Voss
Voss on 25 Mar 2024
v = 3:4:15 % an array
v = 1x4
3 7 11 15
v-v(1) % subtracting the first element from each element
ans = 1x4
0 4 8 12
v(1)-v % subtracting each element from the first element
ans = 1x4
0 -4 -8 -12
  3 Comments
Voss
Voss on 25 Mar 2024
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)
biggestJump = 0.6080
% extra '1':
disp(['Maximum Jump height 1',num2str(biggestJump),' meters'])
Maximum Jump height 10.608 meters
% no extra '1':
disp(['Maximum Jump height ',num2str(biggestJump),' meters'])
Maximum Jump height 0.608 meters

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!