How could I solve the Undefined function or variable 'detectImportOptions'. in MATLAB 2016a?
조회 수: 3 (최근 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
2020년 3월 28일
How are yous using the opts variables later in your code? Are you using them as input to some function?
답변 (2개)
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
2020년 3월 29일
The other option is to use other functions such as csvread(), textscan(), fscanf() to scan the file yourself.
Bajdar Nour
2020년 3월 29일
댓글 수: 2
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');
참고 항목
카테고리
Help Center 및 File Exchange에서 Pattern Recognition and Classification에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!