How to get the index of a row from a range of values in an excel file?
5 次查看(过去 30 天)
显示 更早的评论
采纳的回答
Guillaume
2015-6-12
编辑:Guillaume
2015-6-12
You could use ismember if you want exact comparison (i.e your 0.786 is to be found exactly in the spreadsheet down to the last decimal value).
New in R2015a is ismembertol that allows to specify a tolerance which works better for floating point number (bearing in mind that for computers 0.1 + 0.1 + 0.1 is not equal to 0.3, when using double or single precision numbers).
m = xlsread('somefile.xlsx');
A = 50; C = 59500; E = 0.786;
rows = find(ismember(m(:, [1 3 5]), [A C E], 'rows')); %find exact values
%or
rows = find(ismembertol(m(:, [1 3 5]), [A C E], 1e-4, 'ByRows', true)); %find values within tolerance
edit: a few typos
4 个评论
Guillaume
2015-6-12
links to doc were provided for you to work out the syntax yourself.
Anyway, fixed the typos. It should work now.
更多回答(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!