read selected data from excel datasheet using if statement
1 view (last 30 days)
Show older comments
if have a excel file " testfile" for which i have to slect some data using if statement
i want to read column 4th, 5th and 9th coloumn of this file starting from where coloumn 1 values are >=14 and read it till where cloloum 1 value is <= 16
I have tried the code but it didnot work
A = xlsread('testfile.xlsx')
if (A(:,2)>=14)
then
if(A(:,2)<=15)
then
B = A(:,4);
C = A(:,5)
D = A (:,9)
end
end
0 Comments
Answers (1)
Utkarsh Belwal
on 24 Jun 2019
A(:,2) >= 14 will give a matrix of 0s and 1s, if statement will execute only if A(:,2) >= 14 returns a matrix which has all 1s and according to your xlsx sheet that is not the case so if statement will never be true. Although you can try this code,
A = xlsread('testfile.xlsx') ;
ind = A(:,1) >= 14 & A(:,1) <= 16 ;
B = A(ind , 4) ;
C = A(ind , 5) ;
D = A(ind , 9) ;
0 Comments
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!