readtable in matlab2020 vs readtable in matlab2018

조회 수: 3 (최근 30일)
Mico Kontic
Mico Kontic 2020년 12월 19일
답변: Walter Roberson 2020년 12월 20일
So, I used matlab2020 to make m file. I used readtable function. As stated in documentation starting in R2020a, the readtable function read an input file and ignores headers.
PV_Power_TABLE=readtable('PV_Power.xlsx','Range','C6:CT6');
But my friend is using matlab2018 and and headers exist in his table, and code is not working, because matlab2018 is getting data with headers. How can I change this line, to make code work in matlab2018. So I need matlab2018 to ignore headers as well as 2020. What readtable option should I use ?

답변 (2개)

Cris LaPierre
Cris LaPierre 2020년 12월 19일
편집: Cris LaPierre 2020년 12월 19일
We can't really help you with specifics unless you share the file, as well as specify if it is R2018a or b.
With every release, readtable gets better and better at autodetecting the file format. In an older release, you will need to specify more of the import settings.
You could look at some of the settings here.
You could also have your friend use the import tool to interactively load the data, and then generate a script. You could borrow the settings from the script to determine what settings to add to your import code.

Walter Roberson
Walter Roberson 2020년 12월 20일
readtable does not ignore headers when used with those options.
Current versions of readtable use detectImportOptions automatically unless told not to. With older versions of MATLAB you can call detectImportOptions yourself.
When you use the Range option the difference between between using detectImportOptions or not is that when detectImportOptions is used then MATLAB does a better job of figuring out what Variable Name to use.

카테고리

Help CenterFile Exchange에서 Workspace Variables and MAT Files에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by