read selected data from excel datasheet using if statement
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Utkarsh Belwal
2019-6-24
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!