select part vector put it back in other vector

Dear all,
I want to select the 16th data point from a vector with the 15 points before and after that 16th point. I want to calculate the mean of it and put it back into a new vector. This does also mean that we can start from our 16th value and that the first 15 points should be skipped.
Thanks

2 件のコメント

Kevin Chng
Kevin Chng 2018 年 10 月 25 日
I'm not sure what you are try to do. But take a look at code below
I = [ 1 2 3 4 6 7]
if let say i want to count the mean of 3th to 5th , then replace them by the mean value
s = 3
e = 5
I = [I(1:s-1) mean(I(s:e)) I(e+1:end)]
provided s>1, e<end
Kjell Lemmen
Kjell Lemmen 2018 年 10 月 25 日
Dear Kevin,
I have to the remove outliers to be exactly. I have to calculate the outlier by 3 times the std from the mean. If the 16th value is lower or higher then these 3 times the std difference from the mean that value should be NaN. I do have to calculate the mean and std over a window of 30 points, 15 before that specific value and the 15 points after.
Sorry I was a bit confusing to be honest.

回答 (2 件)

madhan ravi
madhan ravi 2018 年 10 月 25 日

0 投票

S=1:20 %an example
datas=mean([S(1:15) S(17:20)]) %skips 15th element of S vector and calculates its mean
Andrei Bobrov
Andrei Bobrov 2018 年 10 月 25 日

0 投票

S(S./movmean(S,31) >= 3) = NaN;

この質問は閉じられています。

タグ

質問済み:

2018 年 10 月 25 日

閉鎖済み:

2021 年 8 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by