필터 지우기
필터 지우기

what i'am doing wrong?

조회 수: 1 (최근 30일)
Amir Hamzah UTeM
Amir Hamzah UTeM 2011년 4월 11일
mean1=[10;70;90;20];
class1='ST';
class2='AK';
class3='SN';
for j=1:size(mean1,1)
if (0<mean1(j))&(mean1(j)>=60)
class=class1
end
if(61<=mean1(j))&(mean1(j)>=80)
class=class2
end
if(81<=mean1(j))&(mean1(j)>=100)
class=class3
end
end
it show answer :
ST
ST
AK
it should show:
ST
AK
SN
ST
What i'm doing wrong?can someone show me how to do it right?
Thanks, Amir

채택된 답변

Walter Roberson
Walter Roberson 2011년 4월 11일
if (0<mean1(j))&(mean1(j)<=60)
and so on.
  댓글 수: 3
Andrei Bobrov
Andrei Bobrov 2011년 4월 11일
mean1=[10;70;90;20];
class1='ST';
class2='AK';
class3='SN';
out = [];
for j=1:size(mean1,1)
if (0<mean1(j))&(mean1(j)<60), class=class1;
elseif(61<=mean1(j))&(mean1(j)<80), class=class2;
else class=class3;
end
out = [out;{class}]
end
Amir Hamzah UTeM
Amir Hamzah UTeM 2011년 4월 11일
thanks abobroff

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by