Variables name changed when import Excel datas into Matlab
古いコメントを表示
Hello,
I tried to imported a large amount of data from Excel to Matlab but for some reason the variable name got changed to nAN, Anyone know how to keep the original variable name?
For example: My variables name in Excel are Current, Voltage, max output and then it all changed to nAN after got imported to Matlab
3 件のコメント
Walter Roberson
2021 年 2 月 6 日
Which release are you using? How are you doing the importing?
Ive J
2021 年 2 月 6 日
what happens if you try ?
T = readtable('YourFile.xlsx', 'ReadVariableNames', true);
Hui Puong
2021 年 2 月 6 日
回答 (1 件)
Cris LaPierre
2021 年 2 月 6 日
I'd try something like this.
readtable("sampleTable.xlsx","VariableNamingRule","preserve","NumHeaderLines",1)
In R2020b, MATLAB is able to detect that row 3 is not part of the data, and will skip it.
1 件のコメント
If you want to capture the descriptions (row 1) and the units (row 3) along with the variable names (row 2), you can do the following.
opts=detectImportOptions("sampleTable.xlsx");
opts.VariableDescriptionsRange=1;
opts.VariableNamesRange=2;
opts.VariableUnitsRange=3;
opts.PreserveVariableNames=true;
data=readtable("sampleTable.xlsx",opts)
% View the table description and unit properties
data.Properties.VariableDescriptions
data.Properties.VariableUnits
カテゴリ
ヘルプ センター および File Exchange で Data Import from MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

