problem reading table from spreadsheet

1 回表示 (過去 30 日間)
abdul rehman
abdul rehman 2020 年 7 月 16 日
コメント済み: Walter Roberson 2020 年 7 月 16 日
When I use eg by matlab and load data by following everything works
load patients
whos
e.g this code
T = table(Age,Gender,Height,Weight,Smoker,...
'RowNames',LastName)
-----
But when i use my own excel sheet same data no code works, pleas guide my code is as follows
T=readtable("patients.xls");
T = table(Age,Gender,Height,Weight,Smoker,...
'RowNames',LastName)

採用された回答

Walter Roberson
Walter Roberson 2020 年 7 月 16 日
The result of readtable() is already a table . But you might want to
T = readtable("patients.xls");
T.Properties.RowNames = T.LastName;
  2 件のコメント
abdul rehman
abdul rehman 2020 年 7 月 16 日
Thanks Its working, can you help me in one more thing please. I want the complete row where Lastname is Williams and age is 38.
Thanks
Walter Roberson
Walter Roberson 2020 年 7 月 16 日
When you set RowNames, the entries must be unique. You are setting LastName as the RowNames, so the last names must be unique. Therefore the combination lastname Williams and age 38 is either just the same as the entry for williams, or else is empty (in the case the age is wrong.)
T('Williams', :)
Using RowNames is what allows you to use a character vector or scalar string object as the first index into a table... but it does require uniqueness.

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

その他の回答 (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