필터 지우기
필터 지우기

vector subtraction

조회 수: 1 (최근 30일)
Kugen Raj
Kugen Raj 2012년 3월 16일
I have a set of data stored in (kk): kk =
Columns 1 through 8
0 -0.1128 -0.4684 -1.1005 -2.0583 -3.4158 -5.2942 -7.9141
Columns 9 through 16
-11.7597 -18.3555 -56.2068 -19.9206 -15.3116 -13.5578 -13.3223 -14.342
then i used the (diff)command to perform the kk(1)-kk(2) operation. i need to do this until the end: [kk(2)-kk(3)],[kk(3)-kk(4)]..till kk(16).
this is what i get when used the (diff) command:
q =
Columns 1 through 8
-0.1128 -0.3556 -0.6322 -0.9578 -1.3576 -1.8784 -2.6199 -3.8456
Columns 9 through 16
-6.5959 -37.8513 36.2863 4.6090 1.7538 0.2355 -1.0200 -2.4722
for q(1) i suppose to get 0.1128, but im getting a negative value. how can i rectify this problem?

채택된 답변

Sean de Wolski
Sean de Wolski 2012년 3월 16일
Because diff does q(2)-q(1),q(n)-q(n-1).
doc diff
for more info. To correct it, just take the negative.
dqf = -diff(q);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by