What is the difference between xlsfinfo and xlsread?
9 次查看(过去 30 天)
显示 更早的评论
I currently have a code where the file is read in using xlsfinfo. Below I have attached a code that requires xlsread (I think anyway...it does not work when I use xlsfinfo and error codes "Expected to be a cell array, was char instead."). I am unsure whether functions within the rest of the code need specific information from xlsfinfo, or it xlsread would work just fine. If so I do not want to have to read in the file twice using the two file readers. Also I am new to xlsfinfo and would like an explanation of it and the difference between it and xlsread. Thank you!
[~,~,dat]=xlsread('Practice_AFT.xlsx');
%Finds the row and column where the word is...
[~,headerCol_Command] = find(cellfun(@(x)~isempty(strfind(x,'Command')),dat));
dat1=dat(:,headerCol_Command);%extracts the column for Command
0 个评论
采纳的回答
Steven Lord
2018-2-7
The xlsfinfo function returns some information about the spreadsheet whose name you specified as the input.
To use an analogy, xlsfinfo tells you what cereal is in the box you're holding while xlsread pours you a bowl of that cereal. If you already know what cereal is in the box and you just want to eat, use xlsread. If it's dark in the kitchen and you want to make sure before you pour that you're holding a box of cereal not a box of dishwasher detergent, you should use xlsinfo first.
3 个评论
Walter Roberson
2018-2-7
xlsinfo() is often not needed, as it is common to already know the sheet names, and good practice on xlsread() would be to use a try/catch block just in case reading the file failed anyhow. xlsinfo() can be slow, especially on xlsx files on OS-X or Linux.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!