Need to find rows with specific strings
4 次查看(过去 30 天)
显示 更早的评论
I am pulling data in from an excel file and need to check which rows contain a specific string of text
data =7150x1 string
I need to know which rows contain 'xyz'
strfind() returns Search term must be a text or pattern scalar
Contains returns just a 0
2 个评论
Image Analyst
2024-1-18
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:
Dyuman Joshi
2024-1-20
编辑:Dyuman Joshi
2024-1-22
As mentioned, unless we have the file to test what happens, it is difficult to suggest anything.
Please share the file you are working with. Use the paperclip button to attach.
Edit -
"Contains returns just a 0 "
@Charles, Could you elaborate on this? Does it return just a 0? Or all 7150 values are 0?
回答(1 个)
Walter Roberson
2024-1-20
编辑:Walter Roberson
2024-1-20
mask = contains(data, 'what you are looking for');
selected_data = data(mask);
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!