Xlsread for a particular column returns values from another column too?

1 回表示 (過去 30 日間)
Soumyatha Gavvala
Soumyatha Gavvala 2016 年 6 月 17 日
編集済み: Shameer Parmar 2016 年 6 月 18 日
Hello,
I want to obtain the row indices of cells from the Column AD with a particular value, Column X with a particular value, and get the common indices in another array.Here's the code I used:
%Read data1 and select files with the corresponding value
MyData1=xlsread(FileName,'AD:AD'); % read the column
[ir,ic]=find(MyData==2.5); % row, column indices
%Read data 2 and select files with the corresponding value
MyData2=xlsread(FileName,'X:X'); % read the column
[er,ec]=find(MyData2==49);
%Select common files
files=intersect(ir,er);
But, I am getting indices of rows that have these values from another column, here AA. Which I have not specified anywhere. Is there any error in my code?
Thank you.
  5 件のコメント
Soumyatha Gavvala
Soumyatha Gavvala 2016 年 6 月 17 日
Hi,
I fixed this by just selecting the larger set of elements from the column which I need. But if you do find a solution for this situation, feel free to post it. Thank you.
dpb
dpb 2016 年 6 月 17 日
I don't think there is a "situation"; I think there's an error somewhere in the previous work outside what was posted here that we could see that explains the problem you're having.

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

回答 (1 件)

Shameer Parmar
Shameer Parmar 2016 年 6 月 17 日
編集済み: Shameer Parmar 2016 年 6 月 18 日
MyData1 = xlsread(fileName,'Sheet1','AD:AD');
ir = find(ismember(MyData1,2.5));
MyData2 = xlsread(fileName,'Sheet1','X:X');
er = find(ismember(MyData2,49));
files=intersect(ir,er);

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by