Alternatives to using diff(X,2)
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
AtoZ
am 8 Dez. 2018
Kommentiert: Bruno Luong
am 8 Dez. 2018
Just a simple question:
We have an alternative for the opreation diff(A,1) given by A(2:end)-A(1:end-1), from an earlier post.
How to generalize it for diff(A,2)? for say A=[1 2 3 4 5 6]? to get [0 0 0 0].
Thanks.
0 Kommentare
Akzeptierte Antwort
Bruno Luong
am 8 Dez. 2018
Bearbeitet: Bruno Luong
am 8 Dez. 2018
Just apply the same method twice
D1 = A(2:end)-A(1:end-1);
D2 = D1(2:end)-D1(1:end-1)
or
D2 = conv(A,[1 -2 1],'valid')
3 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Numerical Integration and Differential Equations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!