Is there a function that can make new categorical array by sorting numeric data from a table?

8 views (last 30 days)
I am tracking fish location in a tank over time, and want to show graphically a box plot of the fish's x coordinate.
My data goes for a full hour, though, and I need to split that time up into around 10 smaller segments so I can see the average x coordinate of the fish during each time span. I've looked at sort, ordinals, discretize, histcounts, and more and I can't get any of them to do this. They can sort the data into bins by time but don't return the sections in any way that I can then graph. Any ideas what functions I should try?

Accepted Answer

Peter Perkins
Peter Perkins on 27 Nov 2018
I guess your x coordinate is just numeric values. It seems like putting your raw data into a timetable would be the way to go. Then use retime to compute averages within each time bin, and plot tt.X vs. tt.Time (or whatever you called the variables).
  2 Comments
Cichlid Tracker
Cichlid Tracker on 29 Nov 2018
Thanks so much! this is very helpful. Do you know if this sort of function could also be able to retain data within the bins so that max min etc could be found in each one? so that I could make a boxplot with each bin as their own box?
Peter Perkins
Peter Perkins on 11 Dec 2018
Well, you can do anything, and I can think of several ways to retain the raw data for each time bin. But if you want to make boxplots usig the boxplot function in Statistics and Machine Learning Toolbox, then I think you want to keep the original tietable and just add a bin number as a new variable. I think discretize is the best way to do that. Then pass the var you want to make a boxplot of, along with the bin numbers, into boxplot.

Sign in to comment.

More Answers (0)

Categories

Find more on Data Distribution Plots 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!