Borrar filtros
Borrar filtros

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

6 visualizaciones (últimos 30 días)
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 comentarios
Ameer Hamza
Ameer Hamza el 28 de Mzo. de 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 el 29 de Mzo. de 2020
dear Ameer I used a readtable command
times_conf = readtable('result.txt',opts);
times_conf1 = readtable('deathresult.txt',opts1);

Iniciar sesión para comentar.

Respuestas (2)

Ameer Hamza
Ameer Hamza el 29 de Mzo. de 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 comentario
Ameer Hamza
Ameer Hamza el 29 de Mzo. de 2020
The other option is to use other functions such as csvread(), textscan(), fscanf() to scan the file yourself.

Iniciar sesión para comentar.


Bajdar Nour
Bajdar Nour el 29 de Mzo. de 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 comentarios
Ameer Hamza
Ameer Hamza el 29 de Mzo. de 2020
Editada: Ameer Hamza el 29 de Mzo. de 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 el 29 de Mzo. de 2020
Editada: Bajdar Nour el 29 de Mzo. de 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

Iniciar sesión para comentar.

Categorías

Más información sobre Logical en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by