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.

 Akzeptierte Antwort

dpb
dpb am 16 Jun. 2016
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 Kommentare

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!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Azzi Abdelmalek
Azzi Abdelmalek am 16 Jun. 2016
Bearbeitet: Azzi Abdelmalek am 16 Jun. 2016

0 Stimmen

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.

1 Kommentar

I have given a better example of my situation. Please see, thanks!

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by