How to import and use specific columns and rows from excel, based on column titles (and some row value ranges) that can vary from file to file

15 次查看(过去 30 天)
(looking at the attached example excel file ) i want to e able to select a specific column in this case lets say column B , but if another file is used where B is still a title but not in the same location it will still be able to improt the B column automatically. then i want to be able to do calculations in column B based on row values (if a value in column A is a certain value it will only do calculations in those rows); for example if in column A a value has 22 in the B column the same rows will be used for calculations or at least displayed in order to do the calculations . the purpose is to make this code compatible and adaptable with other excell files Capture.PNG

回答(1 个)

Walter Roberson
Walter Roberson 2019-6-6
  1 个评论
Nasir
Nasir 2019-6-6
what would/can i do if instead of simple column headers i have more complicated headers such as "1234 Car Speed ", how would the be put into matlab as proper notation. As i do not have controll over what the column titles are.
t1 = readtable('test1.xlsx');
mask = t1.A == 22;
B22 = t1.B(mask);
% VS
t1 = readtable('test1.xlsx')
mask = t1.1234 Car Speed == 22
B22 = t1.B(mask)

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Data Import from MATLAB 的更多信息

产品


版本

R2014b

Community Treasure Hunt

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

Start Hunting!

Translated by