필터 지우기
필터 지우기

ReadTable producing different result for 2017 and 2020A matlab version

조회 수: 19 (최근 30일)
Lalit Kumar
Lalit Kumar 2022년 4월 29일
편집: Prasanna Konyala 2022년 5월 2일
Hi,
I have created a script which is reading data from excel in matlab 2017v.It's reading whole excel file as it is ,without adding "" for missing value ,not omitiitng any row and setting variable name = VAR1,VAR2....etc
file_name = 'TestCase.xlsx';
excel_sheet = readtable(file_name,'Sheet',1,'ReadVariableNames',false);
Now i have tried running same script in the matlab2020v,it's reading excel in a different way than 2017v.It's omitting row and reading first line as VarName.
file_name = 'TestCase.xlsx';
excel_sheet = readtable(file_name,'Sheet',1,'ReadVariableNames',false);
Update:Added Image
I want MATLAB2020A read excel in the format as it's read by 2017A
  댓글 수: 5
dpb
dpb 2022년 4월 29일
편집: dpb 2022년 4월 29일
I'd probably go back a step and use an import object that matches the expected file structure and form in which want the file to be interpreted. This then should produce the desired consistent results.
I don't know what your 2017 imported file looked like; be good to attach it as a .mat file, but R2020b didn't seem to leave anything out and didn't read variable names...
Lalit Kumar
Lalit Kumar 2022년 4월 30일
@dpb added image for better understanding

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

답변 (1개)

Prasanna Konyala
Prasanna Konyala 2022년 5월 2일
편집: Prasanna Konyala 2022년 5월 2일
From my understanding, you want to get the whole data in excel to be read in the same format as 2017a.
From 2020a, "readtable()" functionality is a bit different than earlier versions. It can detect data types, discard extra header lines, and fill in missing values. In the file attached, it is discarding extra header lines at the start and reading each column as numeric data. Hence, unknown or missing data is replaced by NaN.
If you want the functionality as earlier versions, you can add ('Format','auto') name-value pair argument to the readtable function in 2020a.
file_name = 'TestCase.xlsx';
excel_sheet = readtable(file_name,'Sheet',1,'ReadVariableNames',false,'Format','auto');
Please refer this document for more information about "readtable()"

카테고리

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

제품


릴리스

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by