Howe can I subtract neighboring numbers?

1 view (last 30 days)
Hello,
I got a matrix like this:
>> z=[1,2,3,4]
z =
1 2 3 4
How can I substract the neighboring numbers?
Like 2-1; 3-2; 4-3; etc.
And how can I divide every number by 60 ?
Like 1/60 2/60 etc

Accepted Answer

Andrei Bobrov
Andrei Bobrov on 7 Jul 2019
diff(z)
z/60
  5 Comments
Andrei Bobrov
Andrei Bobrov on 7 Jul 2019
Edited: Andrei Bobrov on 7 Jul 2019
diff([0,z(:)'])
or
diff([0;z])

Sign in to comment.

More Answers (0)

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!