read selected data from excel datasheet using if statement
2 ビュー (過去 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 で Data Import from MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!