Import data from Excel, based on the cell content

I want to import a set of data corresponding to a particular cell value, for example,
Here, I want the select all the data where AD=2.57 and delete the rest of the data.

 采纳的回答

Wrong approach -- read the data, then eliminate that which isn't wanted.
x=xlsread('yourfile.xls');
x=x(x~=5);
If you need to know from whence they came then either
[ir,ic]=find(x==5); % row, column indices
ix=(x==5); % logical array
before removing the values.
Otherwise, if adamant, use ActiveX and it becomes a question of Excel syntax, not Matlab...

3 个评论

I have given a better example of my situation. Please see, thanks!
Same answer still holds except read the column of interest...
[~,shts]=xlsfinfo('yourfile.xls'); % get sheet name
x=xlsread('yourfile.xls',char(shts),'AD:AD'); % read the column
Previous as before for the value of interest; you may need the tolerance to test a floating point value for equality to within a small difference owing to fp rounding issues.
Thank you! That solved my problem!

请先登录,再进行评论。

更多回答(1 个)

Azzi Abdelmalek
Azzi Abdelmalek 2016-6-16
编辑:Azzi Abdelmalek 2016-6-16
Use xlsread to import your data, then take what you want. I think what you want is to locate the number 5 for example in your matrix.

Community Treasure Hunt

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

Start Hunting!

Translated by