How could I solve the Undefined function or variable 'detectImportOptions'. in MATLAB 2016a?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Ameer Hamza
le 28 Mar 2020
How are yous using the opts variables later in your code? Are you using them as input to some function?
Réponses (2)
Ameer Hamza
le 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.
1 commentaire
Ameer Hamza
le 29 Mar 2020
The other option is to use other functions such as csvread(), textscan(), fscanf() to scan the file yourself.
Bajdar Nour
le 29 Mar 2020
2 commentaires
Ameer Hamza
le 29 Mar 2020
Modifié(e) : Ameer Hamza
le 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');
Voir également
Catégories
En savoir plus sur Pattern Recognition and Classification dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!