How do i write a function containing a loop for two vectors?
1 view (last 30 days)
Dear Community, I have to create 2 vectors one expressing an upper boundary of 5% and a lower boundary of 5%. These 5% each have to be "removed" from my original plot. My original plot is described on the x axis by milliseconds up to 20000ms and my y axis deals with the values between 0 and 1. The plot is called from a dataset with this command:
If my lower and upper boundary are defined by
Now I would like to create a loop for both upper and lower boundary for 10000 values like this:
lowerB(1000) =s(1000, 50)
and the same for upper boundary:
upperB(1) = s(1,950)
Could somebody help me write this in a loop? Thank you very much!
Jenny, why on earth would you want to write that in a loop?(Is that a homework assignment?) And do you really need to calculate (and keep) the upperB and lowerB matrices? Or do you just want to eliminate them, keeping only the 5th through 95th percentiles? If the latter, you can just do something like this:
bounds = prctile(s,[5,95]);
keepvals = a(a>=bounds(1) & a<=bounds(2));
And, if you need them:
discards = setdiff(a,keepvals);
lowerB = discards(discards<=bounds(1));
upperB = discards(discards>=bounds(2));
I can tell you how to discard your outliers, but I can't tell you if you should. (Is that what you're asking?)
I would guess that that's kosher as long as you report your methods, but then i'm not a statistician.