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

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일

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

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

댓글을 달려면 로그인하십시오.

카테고리

질문:

2016년 6월 16일

댓글:

2016년 6월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by