Index exceeds the number of array elements (0).
Afficher commentaires plus anciens
clc
clear all
close all
myDir = 'C:\Users\bpeoples\Downloads\SCANSNAPCODE_BDP\Numerical Comparison\Diffused Above, SV600 Raised\1st 25'; %call out folder contained in image
ext_img = '*.jpg'; %file extension of interest
a = dir([myDir ext_img]); %array of all files in folder with .jpg ext
nfile = max(size(a)) ; %file count
%read all images into a single struct
for i=1:nfile
my_img(i).img = imread([myDir a(i).name]);
end
Keep getting the error: Index exceeds the number of array elements (0).
1 commentaire
dpb
le 1 Juil 2019
Have you used the debugger and checked what the file name is that you actually passed to dir()?
Hint: The solution could make use of fullfile()
Réponse acceptée
Plus de réponses (1)
Enguerrand Galmiche
le 20 Fév 2023
This Code :
%Ce programme sert à analyser les fonctions de corrélations en fonction du
%RMSD de différents complexes protéines - ligand
experience='Analyse_Corr_RMSD_Prot_Lig';
extension='csv';
%Récupération des données dans le dossier de l'expérience
File_Corr_Data=dir(fullfile('C:\Users\Stagiaire\Desktop\Enguerrand\Prot_Lig_Neu_MoProCommandLine', ['*.',extension]));
filelist=dir(fullfile('C:\Users\Stagiaire\Desktop\Enguerrand\Analyse_Pose_Docking\Données_Brutes', ['*.',extension]));
Correlations_P1xP2_P1xP3_data = csvread('C:\Users\Stagiaire\Desktop\Enguerrand\Prot_Lig_Neu_MoProCommandLine\Analyse_Corr_data.csv');
nfiles=length(filelist);
disp(filelist)
for ifile=1:nfiles
disp(['Traitement du fichier n° ',sprintf('%d',ifile)])
filename = fullfile('C:\Users\Stagiaire\Desktop\Enguerrand\Analyse_Pose_Docking\Données_Brutes',filelist(ifile).name); % Récupération du nom de fichier complet
disp(filename)
%Initialisation des vecteurs
RMSD=[];
Glide_Score=[];
Correlations_P1xP2_P1xP3=[];
for i=1:length(filename)
RMSD_data = csvread(filename, 1, 1);
RMSD = RMSD(:,1);
Glide_Score_data = csvread(filename, 1, 2);
Glide_Score = RMSD(:,2);
Correlations_P1xP2_P1xP_3_data=csvread(Correlations_P1xP2_P1xP3_data,0,0);
Correlations_P1xP2_P1xP3=Correlations_P1xP2_P1xP3(i,1);
disp (RMSD)
disp (Glide_Score)
disp (Correlations_P1xP2_P1xP3)
end
end
%Calcul du produit de corrélation par le glide_score
Prod_Corr_Score = Correlations_P1xP2_P1xP3*Glide_Score;
%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 j=1:nfiles
Count_RMSD = unique(Int_RMSD);
end
%Calcul de la fréquence de chaque valeur de RMSD
X_max = max(Prod_Corr_Score); %Cherche la valeur de RMSD la plus grande dans la matrice Eff_RMSD
Eff_Corr = hist(Prod_Corr_Score,X_max); %build input vector
Freq_Corr = Eff_Corr/length(Int_RMSD); % histogramme normalisé
Freq_Corr_Percent = 100*Freq_Corr;
Cumul_Corr = cumsum(Freq_Corr_Percent);
figure
bar(Cumul_Corr);
figure
axis on
plot(Cumul_Corr,'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')
Return the error : Error in Analyse_Corr_RMSD_Prot_Lig (line 22)
RMSD_data = csvread(filename, 1, 1);
1 commentaire
Enguerrand Galmiche
le 20 Fév 2023
What is possible for solve this problem ?
Catégories
En savoir plus sur Matrix Indexing 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!