nanmean problem (bachelor thesis help!)

1 次查看(过去 30 天)
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
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