1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
function listbox1_CreateFcn(hObject, eventdata, handles)
directory_name = uigetdir('C:\);%open path
files=dir(directory_name) %acquiring path
list = files %acquiring of structur of files
str = {list.name} %acquiring of name of file
[s,handles.nb_files] = size(str); %elements in the folder
set(gcbo,'str',str)
handles.nb_files=handles.nb_files-2 %correcting because of . and ..
strr=str
for a = 1:handles.nb_files
x(a)=strr(a+2);%storage of file name
end
n=1;
%cutting of file name
for n = 1:handles.nb_files %loop to process all the files
S = char(x(n)); %enforce the type of data
rem = S;% provide the string to cut
[strg, rem] = strtok(rem, '_'); %cut the string
file(n).driver=strg;
[strg, rem] = strtok(rem, '_');
file(n).num1=strg;
[strg, rem] = strtok(rem, '_');
file(n).distance=strg;
[strg, rem] = strtok(rem, '_');
file(n).type=strg;
[strg, rem] = strtok(rem, '_');
file(n).lenght=strg;
[N]=n;
file(n).indice=[N];
end
guidata(gcbf,handles)
% hObject handle to listbox1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: listbox controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit1_Callback(hObject, eventdata, handles,nb_files)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles=guidata(gcbf);
type_taken=get(hObject,'String') %returns contents of edit1 as text
%str2double(get(hObject,'String')) returns contents of edit1 as a double
for n = 1:handles.nb_files
results=strcmp(file(n).type,type_taken);%compare string length et les valeurs des lenght
if results==1
indice(n).type=n
else
indice(n).type=0
end
end |
Partager