- I think the short answer is that you just want a | (vertical bar) rather than a &, right? You could also use ismember, but for two authors, probably just a good to spell it out.
- If you haven't already done so, it's likely that you want to convert some of your data from text to categorical.
- If you find yourself needing to do calculations across all groups in your data, you may find varfun or rowfun, with the GroupingVariables parameter, useful. Hard to say without know what you're doing.
How do I: Create a table using a Query on a Larger Table
8 views (last 30 days)
Show older comments
Hello,
I have a "master" table of data with "x" number of rows and "y" number of columns. The table contains test results for "x" number of specimens. There are "y" number of measured results. However, not every possible measured value was recorded for each "x" test. This is a compilation of test data from various researchers, so there are naturally gaps in the data.
What I am currently doing is querying the master table to perform calculations on the data. Of course I can't perform calculations on the entire table at once, so I have to select which rows I want to use as inputs to my calculation. So I have something like this:
T = allData;
rows = T.Form=="Round" & T.Color=="Blue" & T.Author=="Smith";
vars ={'Form','Color','Author','Mass','Height','Speed');
T_calc = T(rows,vars);
I select the rows and the vars manually based on the calculation that I want to do, and then do those calculations using the T_calc table.
This can be time consuming, but the real issue is that if I want to do the same calculation using data from two authors:
rows = T.Author=="Smith" & T.Author=="Jones"
I can't find a way to do it. The code above is just an example to give you an idea of what I am trying to do, but I haven't found a way to do it. So my questions are:
- Is there a better way to do this (It'd be nice to simply have a form that I can select what I want for "rows" and "vars" and hit go.
- If the way I am doing it now is the easiest way, how can I do: T.Author==EitherOr?
I imagine there is a much easier way but I haven't found it just yet.
Thank you so much!
0 Comments
Answers (1)
Peter Perkins
on 8 Mar 2018
A couple things:
Hope this helps.
See Also
Categories
Find more on Tables in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!