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