How to obtain the absolute difference between elements in column?
Afficher commentaires plus anciens
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?
Réponses (1)
Walter Roberson
le 19 Mar 2018
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()
Catégories
En savoir plus sur Images dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!