I have following code, I wanna give label to a matrix with 1 or -1 based on the type. I know it will give an error "Subscript indices must either be real positive integers or logicals." But I don't have any idea how to fix it.
if jenis == 1
T(feature)= 1;
else
T(feature)= -1;
end
Please help me anyone. Thank you.

댓글 수: 2

dpb
dpb 2016년 11월 16일
If you mean feature is supposed to be -1|1, then no, "You can't do that!". Scale to use [1|2] instead if insist on using array indices as the segregating method.
Rather, I'd suggest keeping a corollary variable instead; it could be categorical rather than numeric. The table might be useful here... <table>
Image Analyst
Image Analyst 2016년 11월 16일
What is jenis? A scalar? Your matrix?
What is feature? It must be natural integers starting with 1, like 1,2,3,4,5,....etc.
What is the name of your matrix? jenis? Or T? Or something else???

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

답변 (1개)

Jan
Jan 2016년 11월 16일

0 개 추천

What about using a struct?
T.data = rand(5);
T.feature = -1; % or +1

댓글 수: 2

Tuffahatul Ummah
Tuffahatul Ummah 2016년 11월 16일
편집: Tuffahatul Ummah 2016년 11월 16일
Sorry, but the toolbox I use can't receive a struct data.
dpb
dpb 2016년 11월 16일
Well, it would certainly help to see an actual illustration of how you think you need to use this "feature"...otherwise we're only able to say "here's a rock" and you keep saying, "no, not that rock!" (much like a DOE program manager I worked for many, many years ago until I finally broke him :) ).

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

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

제품

질문:

2016년 11월 16일

댓글:

2016년 11월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by