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

조회 수: 8 (최근 30일)
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
Ameer Hamza
Ameer Hamza 2020년 3월 28일
How are yous using the opts variables later in your code? Are you using them as input to some function?
Bajdar Nour
Bajdar Nour 2020년 3월 29일
dear Ameer I used a readtable command
times_conf = readtable('result.txt',opts);
times_conf1 = readtable('deathresult.txt',opts1);

댓글을 달려면 로그인하십시오.

답변 (2개)

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

댓글을 달려면 로그인하십시오.


Bajdar Nour
Bajdar Nour 2020년 3월 29일
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
Ameer Hamza
Ameer Hamza 2020년 3월 29일
편집: Ameer Hamza 2020년 3월 29일
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 2020년 3월 29일
편집: Bajdar Nour 2020년 3월 29일
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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by