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 view (last 30 days)
Show older comments
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
0 Comments
Answers (1)
Cris LaPierre
on 2 Nov 2023
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.
0 Comments
See Also
Categories
Find more on Tables 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!