error -index must be a positive integer or logical.

I have code for rbf function with cv
xdata=[0.5 25 1 0 ;8 9 21 0;12 25 1 0 ;8 9 21 0; 12 25 1 1 ;8 9 21 0]
ydata=[2 6 9 .6 ;2 8 7 4 ;2 6 9 8 ;2 8 7 4;2 6 9 8 ;2 8 7 4]
training=xdata(:,1:4);test=xdata(:,3:4);
groups=xdata(:,end);cp = classperf(groups);
samplesize=size(xdata);
samplesize=size(xdata);
c=cvpartition(samplesize,'kfold',2);
cp = classperf(groups);
for i=1:2
trainInd = find(c.training(i));
testInd = find(c.test(i));
trainXMat=xdata(xdata(trainInd));
tstXMat=xdata((xdata(testInd)));
trainYMat=ydata(ydata(trainInd));
tstYMat=ydata((ydata(testInd)));
cp = classperf(cp, trainInd , trainInd )
end
i get error as
Attempted to access xdata(0.5); index must be a positive integer or logical.
Error in ==> yasrbf at 20
trainXMat=xdata(xdata(trainInd));
please help
some of my data in xdata and ydata have values in range 0 to 1

답변 (2개)

Walter Roberson
Walter Roberson 2012년 4월 10일

0 개 추천

Why are you using xdata(xdata(trainInd)) instead of just xdata(trainInd) ?

댓글 수: 1

kash
kash 2012년 4월 10일
Thanks walter it works but
CorrectRate: 0
ErrorRate: 1 ,why do i get like these

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

Jan
Jan 2012년 4월 10일

0 개 추천

As the error message tells clearly, indices must be positive integers. You cannot access the element between the zero'th and the first one like "xdata(0.5)".
Perhaps you want xdata(trainInd) without a further nesting.

댓글 수: 1

kash
kash 2012년 4월 10일
Thanks JAn it works but
CorrectRate: 0
ErrorRate: 1 ,why do i get like these

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

카테고리

도움말 센터File Exchange에서 Guidance, Navigation, and Control (GNC)에 대해 자세히 알아보기

태그

질문:

2012년 4월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by