Sort data, plot means, std errors

Given a matrix with y, x and z columns, plot graphs of y vs x for each z, with error bars.
2.2K Downloads
Updated 25 Oct 2009

View License

Syntax: [curvestructarray, relevant_data] = meansemfun(datasource, xcolindex, ycolindex, zparamcolindex)

Given a data matrix (datasource) with columns for y, x and (optionally) z, sort the data and create a graph showing y vs x for each z, with error bars.

In the data matrix each row typically represents an observation, with columns for the independent (x axis) and dependent (y) variables. The second independent variable (z), if present, is used for distinguishing among different curves to be plotted. There can be any number of rows, with x and z (curve-parameter) values recurring in any order and with any frequency. The x values can be different for the different curves.

All arguments are optional. If no arguments are supplied, the user is asked to specify a file source for the data, by entering the name of a text file that contains the data matrix. Arguments 2:4 are the column indices for x, y, and (optionally) the curve parameter z; if these are missing, meansemfun asks the user to input them.

Meansemfun plots the mean and +-1 times the s.e.m. of y, versus x, for each value of the curve parameter z. It returns curvestructarray, an array of structures, one for each curve. Fields are X; mean of Y; standard error of the mean of Y; and number of observations, each as a column vectors ordered in ascending order of X; and the (scalar) curve parameter value z, if applicable. Also returned are the relevant data, suitably sorted.

Cite As

Don MacLeod (2024). Sort data, plot means, std errors (https://www.mathworks.com/matlabcentral/fileexchange/20181-sort-data-plot-means-std-errors), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2006b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Shifting and Sorting Matrices in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.1.0.0

comments

1.0.0.0

Fixed bug in plot color selection