Extract specific rows from a table, row names are dependent on user input.
Show older comments
Hello Everyone,
I have a function with two Inputs: table name and a string. The string usually contains information that would be used later in the function to locate spcfic values. Say you have a Table 5X5 and the rows are a,b,c,d,e and you want to find out which values in row c are smaller than 5, the input would be something like ( assuming function name is 'loc' and table name is 'cases'):
loc(cases,"cases.c<5")
The function returns a table that contains all the colmuns containing c values smaller than 5. However the table as a whole is still there, meaning that all the rows are still there, only the colmuns got filtered, and that's where the issue is: I need to automatically plot the values that I got, but the table itself has unecessary rows. So my Idea is to extract the rows/colmuns from the table that I already have and then use the values from a new table that basicly contains only the necessary values that i need for the plot.
Now I thought a good Idea for the new table would be something like this:
idx=cases.c<5;
Table_New=(idx,:)
but with this code I have two Problems: first of all I can't use the input value (cases.c<5) as an index. Even if I entred the idx line in the code, It's not working and I get the message 'Row Index exceeds table dimensions'
If you have an idea on how this can be realised or if you can help it would be much appreciated.
Accepted Answer
More Answers (0)
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!