Hello everyone!
A GUI that I am trying to develop is analysing data from a device. The files with the data that need to be analysed differ in the number of digits to save the files or prefix. For example: ID103215sec.csv or ID0915sec.csv or PreID0392sec.csv. The sec.csv is always fixed. Now I already figured out how to let the user input the prefix 'ID' or 'PreID' and let MATLAB search for files using this prefix and ending in sec.csv by using this code:
function prefix_Callback(hObject, eventdata, handles)% hObject handle to prefix (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of prefix as text
% str2double(get(hObject,'String')) returns contents of prefix as a double
Prefix = get(handles.prefix, 'String');Pattern = [Prefix '*'];handles.Pattern = Pattern;if isempty(Prefix) == 1; Prefixval = 0;else Prefixval = 1;endswitch Prefixval case 1 set(handles.findspecfiles,'Enable','On'); case 0 set(handles.findspecfiles,'Enable','Off');endguidata (hObject,handles);% --- Executes on button press in findspecfiles.
function findspecfiles_Callback(hObject, eventdata, handles)% hObject handle to findspecfiles (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)foldername = handles.foldername;Pattern = handles.Pattern;filePattern = fullfile(foldername, Pattern);theFiles = dir(filePattern);Filenames = struct2cell(theFiles);Filenames = Filenames(1,1:end)';Filestringcheck = strfind(Filenames,'sec.csv');Filestringlogic = cellfun(@isempty,Filestringcheck);if isempty(Filestringlogic) == 1; ErrorFileName = msgbox('No files found with input criteria', 'Error','error');endFilenames = Filenames(Filestringlogic==0);set(handles.text7, 'String', Filenames);
Now, if I want the user to use a edittext or popupmenu for the number of digits between the prefix and sec.csv, how can MATLAB find the files with those specific amount of numbers? MATLAB should then be able analyse all the files in the folder with those specific amount of digits.
Best Answer