필터 지우기
필터 지우기

Choose some data that has a minimum value

조회 수: 2 (최근 30일)
baby
baby 2013년 1월 20일
hello all,,
i wanna asking about how to choose some data that has a minimum value,,
example :
i do input five data
then after that it will choose three data that has minimum value
i've knew that if choose minimum data in matlab use "min" command
but it just give one value
i want in my case, it can choose three data that has minimum value
can someone help me??
this is my code
a= input ('Input Number of Data :');
for c=1:a
int2 = ['Input The First Score - ',num2str(c),' :'];
int3 = ['Input The Second Score - ',num2str(c),' :'];
b(c,1) = input(int2);
b(c,2) = input(int3);
end;
for d = 1 : 1
int4= ['Input The First Data :'];
int5 = ['Input The Second Data :'];
e(d,1) = input(int4);
e(d,2) = input(int5);
end;
x = ( b(:,1) - e(1,1)).^2 + (b(:,2) - e(1,2)).^2;
disp(x)
NB : Sorry for my bad english :)

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 1월 20일
편집: Azzi Abdelmalek 2013년 1월 20일
x=[4 1 3 8 2 0 10]
a=sort(x); % sort x in ascending order
min_value=a(1:3) % choose the 3 first lowest numbers
  댓글 수: 3
Azzi Abdelmalek
Azzi Abdelmalek 2013년 1월 20일
Yes
baby
baby 2013년 1월 20일
if in my case the data has category so how to choose majority category
example :
First | Second | Total |Category
7 | 7 | 16 |Bad
7 | 4 | 25 |Bad
3 | 4 | 9 |Good
1 | 4 | 13 |Good
if i use function min value that u give to me before then the chosen data is data(1),data(3) and data(4) with one category is bad and two category is good
i wanna my final result is chosen by majority category of data
so the final result is "The new data's class is Good"
majority category data is "good" bcoz two data have category "good" and one data have category "bad"
so category "good" is chosen and bad is not chosen
how to make it?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Variables에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by