Index exceeds the number of array elements. Index must not exceed 3.
조회 수: 77 (최근 30일)
이전 댓글 표시
for i=(k+1):5
quotient=floor(((rem*97)+Code(i))/16);
%quotient
rem=mod(((rem*97)+Code(i)),16);
Code(i)=quotient;
end
Index exceeds the number of array elements. Index must not exceed 3.
Error in Transmission_with_file (line 296)
quotient=floor(((rem*97)+Code(i))/16);
댓글 수: 0
답변 (3개)
KSSV
2021년 11월 24일
This error occurs when you try to extract more number of elements then present in the array.
A = rand(1,4) ; % 1x4 array
A(1) % no error
A(end) % no error, it will extract last element
A(5) % error, as there is no 5th element.
In the same way, when you are indexing check the limits of indices. The indices should not exceed the dimensions of the array.
댓글 수: 0
Enguerrand Galmiche
2023년 2월 13일
편집: Enguerrand Galmiche
2023년 2월 13일
Hello,
This code return the error message "Index exceeds the number of array elements. Index must not exceed 6.". The idea is read the values of table Excel and concatenate the values for every iterate of loop. What can I for correct this error and this problem.
Thanks
experience='Analyse_Pose_Docking';
extension='xlsx';
%Récupération de la liste des fichiers de données preésents dans le dossier
%d'expérience
filelist=dir(fullfile('C:\Users\Stagiaire\Desktop\Enguerrand\Analyse_Pose_Docking', ['*.',extension]));
nfiles=length(filelist);
disp(filelist)
%Initialisation des vecteurs
RMSD=[];
Glide_Score=[];
Analyse_Vec=[];
RMSD_Random=zeros(1500,1);
Glide_Score_Random=zeros(1500,1);
%Pour chaque fichier, on récupère des valeurs particulières de données que
%l'on souhaite traiter
for ifile=1:nfiles
disp(['Traitement du fichier n° ',sprintf('%d',ifile)])
filename = fullfile('C:\Users\Stagiaire\Desktop\Enguerrand\Analyse_Pose_Docking',filelist(ifile).name); % Récupération du nom de fichier complet
disp(filename)
% Importation des données de RMSD et De Score de chaque fichier excel
% du répertoire de données
RMSD = xlsread(filename,'B:B');
Glide_Score = xlsread(filename,'C:C');
RMSD_Random = [RMSD(ifile); RMSD];
Glide_Score_Random = [Glide_Score(ifile); Glide_Score];
Analyse_Vec = horzcat(RMSD_Random, Glide_Score_Random); %Concatène les 2 vecteurs dans une matrice
disp(RMSD)
disp(Glide_Score)
disp(Glide_Score_Random)
disp(RMSD_Random)
end
%Initialisations
Double_RMSD = zeros(nfiles,1);
Int_RMSD = zeros(nfiles,1);
Count_RMSD = zeros(nfiles,1);
Double_RMSD = 2*RMSD;
Int_RMSD = fix(Double_RMSD);
for i=1:nfiles
Count_RMSD = unique(Int_RMSD);
end
%Calcul de la fréquence de chaque valeur de RMSD
X_max = max(Int_RMSD); %Cherche la valeur de RMSD la plus grande dans la matrice Eff_RMSD
Eff_RMSD = hist(Int_RMSD,X_max); %build input vector
Freq_RMSD = Eff_RMSD/length(Int_RMSD); % histogramme normalisé
Freq_RMSD_Percent = 100*Freq_RMSD;
Cumul_RMSD = cumsum(Freq_RMSD_Percent);
figure
bar(Cumul_RMSD);
figure
axis on
plot(Cumul_RMSD,'Color','r','LineStyle','-','Marker','^','MarkerFaceColor','r','MarkerSize',5)
title('Evolution du pourcentage de poses de docking en fonction du RMSD')
xlabel('$2 \times RMSD (\AA)$', 'Interpreter', 'LaTeX')
ylabel('% Poses trouvées')

댓글 수: 0
tzofia
2023년 12월 31일
יש לי שגיאה כזאת בקוד MATLAB הנה השגיאה :Index exceeds the number of array elements. Index must not exceed 3.
Error in New_Training_model (line 24)
imshow(imds.Files{perm(i)});
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

