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.

 採用された回答

dpb
dpb 2016 年 6 月 16 日

0 投票

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 件のコメント

Soumyatha Gavvala
Soumyatha Gavvala 2016 年 6 月 16 日
I have given a better example of my situation. Please see, thanks!
dpb
dpb 2016 年 6 月 16 日
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.
Soumyatha Gavvala
Soumyatha Gavvala 2016 年 6 月 17 日
Thank you! That solved my problem!

サインインしてコメントする。

その他の回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 6 月 16 日
編集済み: Azzi Abdelmalek 2016 年 6 月 16 日

0 投票

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 件のコメント

Soumyatha Gavvala
Soumyatha Gavvala 2016 年 6 月 16 日
I have given a better example of my situation. Please see, thanks!

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by