How could I solve the Undefined function or variable 'detectImportOptions'. in MATLAB 2016a?

4 views (last 30 days)
I use matlab 2016a , I know that the command (detectImportOptions) does not defined in 2016a. Is there any other command exist to give the same result instead of (detectImportOptions) in 2016a ?
countryall = ['US'];
for i = 1:length(countryall)
country1 = countryall(i); %specify country to model
%Obtaining and formating data - courtesy of Toshi Takeuchi - https://www.mathworks.com/matlabcentral/profile/authors/951521
result=webread('https://data.humdata.org/hxlproxy/api/data-preview.csv?url=https%3A%2F%2Fraw.githubusercontent.com%2FCSSEGISandData%2FCOVID-19%2Fmaster%2Fcsse_covid_19_data%2Fcsse_covid_19_time_series%2Ftime_series_covid19_confirmed_global.csv&filename=time_series_covid19_confirmed_global.csv','options','table');
deathresult = webread('https://data.humdata.org/hxlproxy/api/data-preview.csv?url=https%3A%2F%2Fraw.githubusercontent.com%2FCSSEGISandData%2FCOVID-19%2Fmaster%2Fcsse_covid_19_data%2Fcsse_covid_19_time_series%2Ftime_series_covid19_deaths_global.csv&filename=time_series_covid19_deaths_global.csv','options','table');
writetable(result,'result.txt','WriteVariableNames',false);
writetable(deathresult,'deathresult.txt','WriteVariableNames',false);
opts = detectImportOptions('result.txt', 'TextType','string');
opts1 = detectImportOptions('deathresult.txt', 'TextType','string');
  2 Comments
Ameer Hamza
Ameer Hamza on 28 Mar 2020
How are yous using the opts variables later in your code? Are you using them as input to some function?
Bajdar Nour
Bajdar Nour on 29 Mar 2020
dear Ameer I used a readtable command
times_conf = readtable('result.txt',opts);
times_conf1 = readtable('deathresult.txt',opts1);

Sign in to comment.

Answers (2)

Ameer Hamza
Ameer Hamza on 29 Mar 2020
In 2016a, readtable does not accept an option: https://www.mathworks.com/help/releases/R2016a/matlab/ref/readtable.html. At best, you can use name value pairs to configure the settings.

Bajdar Nour
Bajdar Nour on 29 Mar 2020
Dear Ameer I want to run this fileexchange files
but it gives me
Undefined function or variable 'detectImportOptions'
could you prefer another option to run it by 2016a?
  2 Comments
Ameer Hamza
Ameer Hamza on 29 Mar 2020
Edited: Ameer Hamza on 29 Mar 2020
Bajdar, I checked the code. Although you can avoid the problem by merely removing opts and opts1 from the readtable call. On 2020a, readtable is able to read it even without providing options as input. I am not sure about R2016a. However, there is a bigger issue here. The code makes extensive use of string datatype. However, the support for that was added from R2016b. So even if you are able to read the tables, it will still require extensive modification of the code to make it work in R2016a.
times_conf = readtable('result.txt');
times_conf1 = readtable('deathresult.txt');
Bajdar Nour
Bajdar Nour on 29 Mar 2020
Edited: Bajdar Nour on 29 Mar 2020
Dear Ameer thank you so much. I have already checked the readtable without ops and ops1 (it works) but as you said other problems start to appear. I think the best way to run the all options is updating my matlab.thanks again

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!