フィルターのクリア

Removing first character from an imported excel heading

1 回表示 (過去 30 日間)
Frank Lehmann
Frank Lehmann 2022 年 8 月 27 日
コメント済み: Frank Lehmann 2022 年 8 月 30 日
I cannot seem to remove the first character from an imported table from an excel spreadsheet it is on the header and the table variable names are the same except for the mandatory “x” as the first letter all other info is imported OK. I tried aligning left centre and right to no avail from excel but can’t seem to get rid of the dreaded “x” any ideas?
  3 件のコメント
dpb
dpb 2022 年 8 月 27 日
Probably your Excel column name is not an allowable MATLAB variable name which has to be modified to be so -- see readtable optional name-value pair 'VariableNamingRule' and try
tData=readtable('YourFile',...otherparameters...,'VariableNamingRule','preserve');
to keep the existing Excel variable name. This require ML release R2019b or later to be available.
I personally don't much recommend using it, however, over fixing the original name to something that is a legal MATLAB variable name because if you do use one of these, you've got to enclose it in quotes or only use it as the content of a variable and indirect addressing everywhere you want to use it. Grossly inconvenient for just a (generally trivial) display sweetener. "The cure is worse than the disease..."
Frank Lehmann
Frank Lehmann 2022 年 8 月 30 日
Thanks everyone, figured it out its because I am using R2018a V and Matlab doesn't recoginise the first character the original spreadsheet heading started with a "2" where as I should have used "Two" instead ie does not accept a digit in lieu of a character. All good now.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by