Effacer les filtres
Effacer les filtres

vector subtraction

1 vue (au cours des 30 derniers jours)
Kugen Raj
Kugen Raj le 16 Mar 2012
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?

Réponse acceptée

Sean de Wolski
Sean de Wolski le 16 Mar 2012
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);

Plus de réponses (0)

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by