plotting the mean and standard deviation of data when there is more than one piece of data collected at a particular point
Afficher commentaires plus anciens
I have a matrix, in one columnn is the day of year and in the other is the data associated with that day of year. On some days of the year there are multiple data points, while others there is one or none. This makes it difficult to plot the information, what I would like to do is plot the data based on the mean and standard deviation of the data. So if data was collected three times on the 320th day of the year then the mean and standard deviation of these three data points would be found out and then when plotted the mean line would go through the mean and the standard deviation would represent error bars. How would I go about this?
Thanks,
Natalie
Réponse acceptée
Plus de réponses (1)
Image Analyst
le 22 Jan 2014
Are you saying that if some day has duplicates, you want to replace them with the mean of the bunch? Like 3 values of 100, 101, and 102 for day #320 would go to only 1 value of 102 for that day?
Why can't you just scan over the days and find out which one has multiples and then delete the unneeded ones? Let's say you found that elements 40,41, and 42 were all for day #320, so you could do
newMean = mean(theMeans(40:42)); % Get new mean
newSD = std(theSDs(40:42)); % Get new SD
% Assign new mean to element 40
theMeans(40) = newMean;
theSDs(40) = newSD;
% Now delete elements 41 and 42 because they are not needed anymore
themeans(41) = [];
theSds(41) = [];
themeans(42) = [];
theSds(42) = [];
3 commentaires
Natalie
le 22 Jan 2014
Image Analyst
le 22 Jan 2014
Natalie, you don't do it manually. You use a loop. Everything I gave you above could be generalized for any number of measurements per day, not just 3. You just use a loop. You do know how to find if a day has more than one measurement, don't you? If not, try unique() or histc() or something like that.
Natalie
le 22 Jan 2014
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!