How can I fix "Error using subsref, index exceeds matrix dimensions"?
Afficher commentaires plus anciens
I've wrote this code. The problem is there are 22 features in the dataset. But it's only generate Feature 1 and its shows the error below at the Command Window. Can you help me how to fix this problem so that all features can be generated successfully? Thank you.
training = csvread ('training.csv');
class = csvread ('class1.csv');
A = prdataset(training,class);
[instances,nvars] = getsize (A);
for i = 1:22
B = [A(:,i) A.labels];
C = B(:,1:2);
[D I] = sort (C(:,1),'ascend');
E = C(I,:);
disp('feature=');disp(i);
disp(E(:,1:2));
original = 1;
nonoriginal = 1;
counter1=1;
while(original<instances)
nonoriginal = original+5; %ideal cutpoint
disp('nonoriginal=');disp(nonoriginal);
truefalse = isequal(E.labels(nonoriginal),E.labels(nonoriginal+1));
disp('truefalse=');disp(truefalse);
if (truefalse == 0) %if different class
original = nonoriginal;
disp('original=');disp(original);
arr(counter1,i) = E(original,1);
counter1 = counter1+1;
else
nonoriginal = nonoriginal+1;
disp('nonoriginal=');disp(nonoriginal);
yesno = isequal(E.labels(nonoriginal),E.labels(nonoriginal+1)); %if same class
disp('yesno1=');disp(yesno);
while (yesno == 1)
nonoriginal = nonoriginal+1;
disp('nonoriginal=');disp(nonoriginal);
yesno = isequal(E.labels(nonoriginal),E.labels(nonoriginal+1)); %if same class
disp('yesno2=');disp(yesno);
end
original = nonoriginal;
disp('original=');disp(original);
arr(counter1,i) = E(original,1);
counter1 = counter1+1;
end
end
end
Command Window
Error using subsref Index exceeds matrix dimensions.
Error in prdataset/subsref (line 18)
Error in Training (line 25) truefalse = isequal(E.labels(nonoriginal),E.labels(nonoriginal+1));
Réponses (1)
ahmad hazime
le 19 Jan 2018
0 votes
I have the same issue any idea?
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!