Pull data from Excel sheet based on 2 conditions

3 次查看(过去 30 天)
I have an Excel sheet that I've imported into MATLAB. In the Excel sheet, cells 2A - 5A represent condition A, while cells 1B - 1F represent condition B. Columns B-F and rows 2-5 represent values based on the 2 conditions. How do I get MATLAB to call a particular value from the Excel sheet by inputting a numerical value for conditions A and B?

采纳的回答

Gillian Rosen
Gillian Rosen 2017-3-13
Hi Rachel, 
I understand that you would like to access the data in a particular cell of an imported Excel spreadsheet by specifying a numerical condition for the row (condition A) and column (condition B). 
Once you import your Excel spreadsheet to a matrix in MATLAB, you can use the 'find' command to find which row and column of the matrix correspond to a particular condition. You can then index into the matrix using your desired row and column. For example: 
% Import spreadsheet data to matrix
myExcelData = xlsread('mySpreadsheet.xlsx');
% Set desired conditions
conditionA = 3.5;
conditionB = 200;
%  Find row and col of desired conditions
[row,~] = find(myExcelData == conditionA);
[ ~,col] = find(myExcelData == conditionB);
% Obtain data at desired conditions
myValue = myExcelData(row,col);
See the documentation for the 'find' function for more information and examples: 
  2 个评论
Ashish Kulkarni
Ashish Kulkarni 2022-1-12
Hi Rosen,
can u tell how to import data from an excel sheet based on conditions while using importdata.
My problem is the file size is too big for import. If I use entire selection, my laptop runs out of memory.
Or whenI load the data using import function, how do I filter it based on a condition and then import it as a table or matrix?
Ashish Kulkarni
Ashish Kulkarni 2022-1-12
The structure of my file is as follows, I want rows related to a particular date only to be imported.
ID_frame TimeStamp MAC ID RSSI Vendor cod sync DeviceID
1 23-05-2019 12:34 e6aa4f2224ee98e98 -78 Unknown SmartPhone 0 1.91E+13
2 23-05-2019 12:34 f7af897c07bf765a9 -90 Unknown SmartPhone 0 1.91E+13
3 23-05-2019 12:35 e6aa4f2224ee98e98 -69 Unknown SmartPhone 0 1.91E+13
4 23-05-2019 12:35 f7af897c07bf765a9 -88 Unknown SmartPhone 0 1.91E+13
5 23-05-2019 12:36 24cb3474f61a53bac -89 Bluegiga Technologies OY Uncategorized 0 1.91E+13
6 23-05-2019 12:36 e6aa4f2224ee98e98 -85 Unknown SmartPhone 0 1.91E+13

请先登录,再进行评论。

更多回答(0 个)

标签

Community Treasure Hunt

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

Start Hunting!

Translated by