How to obtain the absolute difference between elements in column?

Hi I have
a= 4 3 2 1
4 3 1 2
4 2 3 1
I want to know the absolute difference between elements for each of the columns which gives me
b= 0 0 -1 1
0 -1 2 -1
How am I going to do this?

Respuestas (1)

b = diff(a);
would give the sample output you show.
However, your description asks for the absolute difference, and absolute difference is never negative, so your b does not match your question. To match your question you would abs() the diff()

Categorías

Más información sobre Images en Centro de ayuda y File Exchange.

Productos

Preguntada:

el 19 de Mzo. de 2018

Respondida:

el 19 de Mzo. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by