How do I use an if statement to check if a data is present on a excel sheet?
3 次查看(过去 30 天)
显示 更早的评论
I want to create an if condition that should check if student name and ID is present in the excel sheet.
If it is present it shoul execute the code i want it to run.
I am trying xlsread but is not working for me any suggestion?
0 个评论
回答(1 个)
Adam Danz
2021-3-10
At the top of the documentation page for xlsread there is warning that xlsread is not recommended and it suggests alternative functions (readtable, readmatrix).
If you're checking that a particular header (variable name) exists, you can use those function to read in just the header row(s).
If you're checking if a paricular name and ID exists you'll need to read in the entire table and the search the name and ID columns (hint: isequal, strcmpi, ismember).
If you get stuck and have any problems, show us where you're at and describe the issue.
2 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!