6 views (last 30 days)

You will define a function, that given a vector (it could be any kind of data) and the window size returns a vector with the standard deviation of each of the windows used:

function desv = calculateDev(v, windowSize)

Test the function with the following example

>> calculateDev([2 2.1 3 4.2 3 2.3 4.3 4.2 4.5], 2)

ans = 0.8877 1.0243

The first value in the output vector is the standard deviation of the first 5 elements [2, 2.1, 3, 4.2, 3], and the second the standard deviation of the last 4 elements. [2.3, 4.3, 4.2, 4.5]

Sign in to answer this question.

Opportunities for recent engineering grads.

Apply Today
## 2 Comments

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/495962-how-can-i-calculate-the-standard-deviation-of-a-vector-per-windows#comment_776657

⋮## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/495962-how-can-i-calculate-the-standard-deviation-of-a-vector-per-windows#comment_776657

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/495962-how-can-i-calculate-the-standard-deviation-of-a-vector-per-windows#comment_776659

⋮## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/495962-how-can-i-calculate-the-standard-deviation-of-a-vector-per-windows#comment_776659

Sign in to comment.