How to extract table data based on column values?
Mostrar comentarios más antiguos
I have a table, part of which is displayed. I have attached the table in the question. The entries of the tables are 1*1 cell array.

I am trying to extract all the rows based on 'date'.
test_data((cell2mat(test_data.date) == '02/10/2022', :)
It gives me error "Row index exceeds table dimensions." I also get error for 'subjectid' or 'mazenumber' column.
But it works for "feeder" column.
>> test_data(cell2mat(test_data.feeder) == '4',:)
How do I fix this?
Respuesta aceptada
Más respuestas (2)
Jon
el 17 de Mzo. de 2022
Could be you should be using strcmp rather than == to compare the strings
It's a little hard to know exactly how you have the data stored in the table.
Please save your table using
save test_data.mat test_data
and attach the resulting test_data.mat so we can see what is going on.
1 comentario
Atanu
el 17 de Mzo. de 2022
Categorías
Más información sobre Cell Arrays en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!