Plot mean and standard deviation of data at particular intervals

4 visualizzazioni (ultimi 30 giorni)
I have a large amount of data which is not evenly spread. I wish to bin the data so that it is intervals of 0.1 and then for each of the intervals I wish to find the mean and the standard deviation. I then wish to plot this. How would I go about doing this? Thank you
  1 Commento
Marc
Marc il 11 Nov 2013
There are many different ways to approach this. Try 'hist' first off and take a look at the statistics toolbox if you have it.
You could use logical indexing to grab the various intervals. You could use 'find' which often warns you that logical indexing is better, but if you are new to this, then I would suggest looking at the documentation for 'find'.
The nice thing with Matlab is that mean and std work on columns or rows, so with a little thought, it's easy to automate this task.
Give it a little bit more thought and show us some code that is hanging you up. Otherwise, your question is simply to open ended.

Accedi per commentare.

Risposte (1)

Walter Roberson
Walter Roberson il 11 Nov 2013
interval = 0.1;
datamin = min(YourData);
binidx = 1 + floor((YourData - datamin) ./ interval);
binmeans = accumarray(binidx(:), YourData(:), [], @mean);
binstd = accumarray(binidx(:), YourData(:), [], @std);
bincent = datamin + (interval * 3/2) * (0:length(binmeans)-1);
subplot(2,2,1);
plot(bincent, binmeans, 'b');
ytitle('means');
subplot(2,2,2);
plot(bincent, binstd, 'r');
ytitle('standard deviations');
  1 Commento
Natalie
Natalie il 13 Nov 2013
My description wasn't clear enough, sorry. What I have is two columns of data that need to be plotted against eachother. One of them needs to be binned into 0.1 intervals. The mean and standard deviation of the data in the other column that falls into the same interval needs to found and plotted against the intervals. Thanks, Natalie

Accedi per commentare.

Categorie

Scopri di più su Probability Distributions and Hypothesis Tests in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by