Reading multiple columns of an excel sheet to output a range of values. Please see the example

5 ビュー (過去 30 日間)
Hi,
I am reading multiple columns of an excel sheet, where two columns are a set.
Columns from A to Z, which are sets of AB, CD, EF, GH... YZ
Col A: 1 2 3 4 5 6 7 8 9 10
Col B: 0 3 5 15 30 40 55 85 95 100
I need the output values of ColA and ColB, based on i) ColB>5 & ColB<95 ii)ColB>15 & ColB<85
Answer here would be
Casei)
Col A: 3 4 5 6 7 8 9
ColB: 5 15 30 40 55 85 95
Caseii)
ColA: 4 5 6 7 8
ColB: 15 30 40 55 85
I am able to get these values with the following code. However, I am looking for output of other columns as well like for (ColC,ColD), (ColE, ColF)... (ColY, ColZ). Also the size of the the range for all 13 pairs.
D=xlsread('data.xlsx','Sheet3');
c1=D(:,1);
c1(isnan(c1))=[];
c2=D(:,2);
c2(isnan(c2))=[];
c2t90=c2>=5 & c2<=95;
C2t90=c2(c2t90);
C1t90=c1(c2t90);
frd1t90=[C1t90 C2t90];
dt1t90=size(C1t90);
c2t70=c2>=15 & c2<=85;
C2t70=c2(c2t70);
C1t70=c1(c2t70);
frd1t70=[C1t70 C2t70];
dt1t70=size(C1t70);
Look forward to an output.
Thanks,

採用された回答

Gaurav Garg
Gaurav Garg 2019 年 10 月 3 日
Hi,
I understand that you wish to look for output of other columns as well.
What you can try doing is to write a loop which accesses all the columns of D (the matrix which stores data.xlsx Sheet3) and computes the values of columns based on the conditions specified.
An example -
D=xlsread('data.xlsx','Sheet3')
for i=1:2:26
c1=D(:,i);
c1(isnan(c1))=[];
c2=D(:,i+1);
c2(isnan(c2))=[];
c2t90=c2>=5 & c2<=95;
C2t90=c2(c2t90);
C1t90=c1(c2t90);
frd1t90=[C1t90 C2t90];
dt1t90=size(C1t90);
c2t70=c2>=15 & c2<=85;
C2t70=c2(c2t70);
C1t70=c1(c2t70);
frd1t70=[C1t70 C2t70];
dt1t70=size(C1t70);
end
  1 件のコメント
JAGAN MOHAN KUMMARI
JAGAN MOHAN KUMMARI 2019 年 10 月 6 日
Thanks Gaurav,
But I am using the old one only. I still have few more operations from the same data.
Thanks again
Cheers

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

その他の回答 (0 件)

カテゴリ

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