필터 지우기
필터 지우기

i have made an excel sheet which has values in 1st column and 'yes'/'no' in the 2nd. i want to extract values which show 'no' and display it. how can i do that?

조회 수: 1 (최근 30일)
this is the code i was using but ts not working.
data2=readtable("convergencecheck5.xlsx");
A=table2cell(data2);
k=data2{:,2};
k1=string(k);
switch k1
case 'no'
print(k1)
end

답변 (1개)

Cris LaPierre
Cris LaPierre 2023년 11월 2일
I'd do this
data2=readtable("convergencecheck5.xlsx","TextType","string")
data2.Values(data2.Converge=="no")
You haven't shared your file, so this is more of a template that a guaranteed working example. There is no need to convert you table to a cell. See the Access Data in Tables page to learn how to work with tables.
I have assumed your first table variable (column) is called "Values" and your second variable name is "Converge". These should be whatever column heading you have in your file. If you print out data2 you will see the names used in MATLAB. If you don't have column headings, it will be "Var1" and "Var2".
I then use logical indexing to extract and display the values that have a corresponding "no". Just note that, for this comparison, capitalization matters.

카테고리

Help CenterFile Exchange에서 Tables에 대해 자세히 알아보기

태그

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by