フィルターのクリア

nanmean problem (bachelor thesis help!)

1 回表示 (過去 30 日間)
D.T. van der Meulen
D.T. van der Meulen 2015 年 5 月 31 日
コメント済み: Image Analyst 2015 年 6 月 2 日
Hi!
I'm writing a script where I'm analysing gait data. I calculated the stride velocity by dividing stride length by stride time and it gives me the velocityL vector with some NaN where the SD is greater than 2 times the mean.
Now I wanna delete any wrong values that were created by calculating the velocityL. Because there are NaN is the vector, I used nanmean:
% %remove wrong values
% VelocityL(VelocityL>(nanmean(VelocityL)+SD*nanstd(VelocityL)))= NaN;
However, matlab says that nanmean(VelocityL) is inferior, so the script above won't work.
Does anyone know the solution to my problem?
Thanks in advance! Rik

採用された回答

Image Analyst
Image Analyst 2015 年 5 月 31 日
All your code is in comments so it won't generate any error at all. And, what is the value of SD? Is it 2? What is the values in VelocityL? Without these we can't run your code and recreate your error. You didn't even paste in the error so we don't know what it said. Please copy and paste in all the red text that you see from the error message back here so we can decipher it.
  2 件のコメント
D.T. van der Meulen
D.T. van der Meulen 2015 年 6 月 2 日
Thanks for your reply.
Indeed, SD = 2. The values in VelocityL are like this:
Inf
3,56453829563124
NaN
NaN
NaN
NaN
NaN
NaN
0,409564278065197
0,557640201673890
NaN
0,614743629694066
0,685943864947752
0,788112282608062
0,731369659147766
0,861933814298274
It says that nanmean(VelocityL) = inf.
This is probably because the array starts with inf. Does anyone know how to fix this?
Image Analyst
Image Analyst 2015 年 6 月 2 日
VelocityL = [...
Inf
3.56453829563124
NaN
NaN
NaN
NaN
NaN
NaN
0.409564278065197
0.557640201673890
NaN
0.614743629694066
0.685943864947752
0.788112282608062
0.731369659147766
0.861933814298274]
% Remove inf from the array.
VelocityL(VelocityL== inf) = [];
% Now get means of non-nan values.
meanV = nanmean(VelocityL)

サインインしてコメントする。

その他の回答 (0 件)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by