How do I create such matrix ? (please look at the thread for further details)

조회 수: 1 (최근 30일)
Derick Wong
Derick Wong 2013년 12월 24일
답변: Image Analyst 2013년 12월 24일
Hi,
Let say I have a matrix of m column. eg[X1 X2 X3 X4 ... Xm].
How do I create a matrix that becomes [X1 X2-X1 X3-X2 X4-X3 ... Xm-Xm-1]for m columns ?
And if I have n rows and m column, how do I create such matrix?

답변 (2개)

Azzi Abdelmalek
Azzi Abdelmalek 2013년 12월 24일
편집: Azzi Abdelmalek 2013년 12월 24일
v=[10 50 200 1000]
out=[v(1) diff(v)]

Image Analyst
Image Analyst 2013년 12월 24일
Alternative ways that could be extended for subtracting more than 2 columns, but Azzi's method is probably better/simpler/easier to understand for subtracting just 2 columns.
outc = [v(1), conv(v, [1,-1], 'valid')] % 1D
outc2 = [v(:,1), conv2(v, [1,-1], 'valid')] % 2D

카테고리

Help CenterFile Exchange에서 Specialized Power Systems에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by