Undefined function or variable 'detectImportOptions'.
Mostra commenti meno recenti
I have a code which is supposed to collect data from multiple text files. (I will attach two of them here). The code used is as follows.
function GUI_for_log_OpeningFcn(hObject, eventdata, handles, varargin)
disp('Please wait');
f = dir('*.log');
handles.alldatatable = [];
for ii = 1:numel(f)
DayFile = f(ii).name;
opts = detectImportOptions(DayFile);
opts = setvartype(opts,1,'datetime');
opts = setvaropts(opts,1,'InputFormat','dd.MM.uuuu HH:mm:ss');
table1 = readtable(DayFile,opts);
if isempty(handles.alldatatable)
handles.alldatatable = table1;
else
handles.alldatatable = [handles.alldatatable; table1];
end
end
%disp(handles.alldatatable);
disp('Ready to use');
setappdata(0,'totData',handles.alldatatable);
str = {f.name};
set(handles.listbox1,'String',str); %set string
%evalin('base','clear all');
%evalin('base','clc');
listString = get(handles.listbox3,'String');
assignin('base','listString',listString);
This works fine on any Matlab which is after 2016b, but how do I alter this code to use it on a Matlab before 2016b? The error that comes if I use it in an older version is
Undefined function or variable 'detectImportOptions'.
Error in GUI_for_log_GUI_for_log_OpeningFcn (line 56)
opts = detectImportOptions(DayFile);
Error in gui_mainfcn (line 220)
feval(gui_State.gui_OpeningFcn, gui_hFigure, [], guidata(gui_hFigure), varargin{:});
Error in GUI_for_log (line 42)
gui_mainfcn(gui_State, varargin{:});
The issue is with 'detectImportOptions' which is not available in versions before 2016b. Is there an alternative function I can use instead of this function in, say, 2015a? Or perhaps is there a way to install a toolkit to use this code without alterations?
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Data Type Identification 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!