MATLAB Operation question.

2 ビュー (過去 30 日間)
Kyle
Kyle 2011 年 6 月 7 日
HI,
I have an array:
angle =
Columns 1 through 5
174.8310 -4.9214 -5.0368 -5.0544 -4.2956
Columns 6 through 9
-2.9111 -5.0442 -5.7359 -5.0155
I would like to filter off the number that has less occurrence( Eg. 174.831 , -2.9111) while keeping those value that repeats.
Is there any matlab function that can do that?
Thanks

採用された回答

the cyclist
the cyclist 2011 年 6 月 7 日
% Identify the elements that are too high or too low
isTooHi = (angle>-4.5);
isTooLo = (angle<-5.5);
% Remove them
angle(isTooHi|isTooLo) = [];
  1 件のコメント
Kyle
Kyle 2011 年 6 月 8 日
Thanks a lot.
you given me an idea. I slightly modify ur code to suite my use.
angle=[-2.9111 -5.0442 -5.7359 -5.0155 174.8310 -4.9214 -5.0368 -5.0544 -4.2956];
b=round(angle);
c=mode(b);
isTooHi = (angle>(c+1));
isTooLo = (angle<(c-1));
angle(isTooHi|isTooLo) = []

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

その他の回答 (1 件)

John D'Errico
John D'Errico 2011 年 6 月 7 日
NONE of these numbers are repeated in your example! Unless you define what numbers are desirable, MATLAB cannot know that one number is better than another when all are distinct. MATLAB cannot read your mind.
My guess is you are looking for an outlier detection/removal scheme. If so, then you need to either define it in terms of the expected distribution of these numbers (i.e., a normal distribution) or do so using some non-parametric scheme.
  1 件のコメント
Kyle
Kyle 2011 年 6 月 7 日
Thanks for the reply.
Sorry i should be more specific. For my example i would like to keep all those value that are -5 +/- 0.5 while eliminates others outside this range.
Other array would have maybe a lot value near 7 while a few value is far off(like 1, -20,...)

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

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by