??? Index exceeds matrix dimensions
Mostra commenti meno recenti
hi, can anyone help me with this error ??? Index exceeds matrix dimensions..here is my code
close all;
clear all;
lambda2 = [2 4 6 8];
theta2 = [0*pi/180, 45*pi/180, 90*pi/180, 135*pi/180, 180*pi/180, 225*pi/180, 270*pi/180, 315*pi/180];
no_lamd = 4;
no_theta = 8;
psi = [0 pi/2];
gamma = 0.5;
bw = 1;
N = 1;
%%%%%%%%%%%%%%%%%%%%%%%%
ext = '.bmp';
dirr = 'D:\GPDSdataset\';
%[tr_data, tr_class, x, y, answer] = textread('train_file.txt','%s %d %f %d %s'); %train
[tr_data] = textread('trainfile_source.txt','%s'); %train
[mtr ntr] = size(tr_data);%mtr
%assign class no
model = 100;
train = 5;
cnt = 0;
for i=1:5:5*model
cnt = cnt + 1;
for j = 0:1:4
ts_class(i+j)=cnt;
end
end
save ts_class ts_class
%select train image
model = 100;
cnt1 = 0;
cnt2 = 0;
for j = 1:20:20*model
for i = 0:1:4
cnt1 = cnt1+1;
AR_train(cnt1)= tr_data(j+i);
end
cnt2 = cnt2+1;
AR_test(cnt2) = tr_data(j+5);
end
size(AR_train');
size(AR_test');
??? Index exceeds matrix dimensions.
3 Commenti
Jan
il 26 Ago 2011
@Mo: Have you read a little bit in this forum before posting the first time? We ask the authors again and again and again to format the code, such that it is readable. Either start the code lines by two spaces, or mark the code and hit the "{} Code" button. There is a link called "Markup" on this page, which explains the details. And Oleg spent some time to create this nice tutorial: http://www.mathworks.com/matlabcentral/answers/13205-tutorial-how-to-format-your-question-with-markup .
Then it would be more efficient, if you post the line, which causes the error. Although the contributors are very enganged to fix bugs, but it is your turn to describe it as good as possible.
Mo
il 26 Ago 2011
Sean de Wolski
il 26 Ago 2011
The error message probably says what line the indexing error is on as well, please report that.
Risposte (1)
Jan
il 26 Ago 2011
Using the debugger would lead you to a solution efficiently:
dbstop if error
Then start the program. Now MATLAB stops, when the error occurs and you can inspect the current values of the variables in the command window or workspace browser. Finally you can find out by yourself, which index exceeds which dimension of which variable.
Categorie
Scopri di più su Matrix Indexing in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!