Movslope
Description
movslope(vx, vy[, n]) function returns a vector to calculate the moving slope at each point with a window width of n and (n-1)/2 points on either side of the point.
The slope at point i with a width of k is:
/math-297aeee92145f43ddc8d21f4a49dd7af.png)
Where
,
,
and /math-ec32c5094253a81f702c857d0e42be49.png)
Syntax
vector movslope(vx, vy[, n])
Parameters
vx
- Input vector for independent variable
vy
- Input vector for dependent variable
n
- Input integer for window width
- n should be an integer greater than 1. If n is an even number, it will be set to n+1 internally. When n is omitted, the function returns a vector of one value which is the linear fit slope of the input.
Return
Return the moving slopes at each point with a window width of n.
The first and last (n-1)/2 points of the output vector are missing values.
Note: If there are missing values in vx or vy, the slopes related to these points in the n window will be missing values. If a slope is infinite, it will be shown as a missing value.
Example
//Col(C) will be filled with slopes at each points. //First and last two cells are missing values. col(C)=movslope(col(A),col(B),5);
//Col(C) only has a numeric cell, which is the slope for all the points. col(C)=movslope(col(A),col(B));