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?

답변 (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()

카테고리

도움말 센터File Exchange에서 Images에 대해 자세히 알아보기

제품

질문:

2018년 3월 19일

답변:

2018년 3월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by