Search for a value in a table and get the corresponding value from the 2nd column
9 次查看(过去 30 天)
显示 更早的评论
Hi guys,
I have a table of values and would like to search for a value and then get the corresponding value from the 2nd column. Can anyone help me with this problem?
Thanks a lot!
0 个评论
采纳的回答
Star Strider
2023-4-2
If you are searching for an exact match, try something like this —
Col1 = linspace(0, 10, 21).';
Col2 = randn(numel(Col1),1);
T1 = table(Col1,Col2)
Val = 3;
Result = T1{Col1==Val,:}
Much depends on the table and what you want to do. This is simply an illustration of the most obvious approach.
.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Cell Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!