Quantcast
Channel: MATLAB Central Newsreader - tag:"median"
Viewing all articles
Browse latest Browse all 22

Re: standard deviation, confidence interval and more.

$
0
0

"Sara " <tjockpojken@gmail.com> wrote in message
news:m4hor2$6hk$1@newscl01ah.mathworks.com...
> Hi!
>
> I'm a rather unexperienced MATLAB user. I barely manage to get along by
> googling and trial and error.
> Now I'm facing a problem google can't seem to solve for me.
> I have an expermimental setup that exports various sensor readings in the
> form of .txt files. The expermimental setup does the same thing over and
> over, exporting one file each time, meaning I have loads of files looking
> about the same (run1, run2, run3, run4 etc). The files contain 5000
> samples each. I import these files into MATLAB using the textscan
> function. I store each run (loop) of the experimental setup in a cell
> array. So, if i loop my setup say 8 times I'll end up with a cell array
> containing 8 5000x1 double.

If you're certain that all the files contain the same amount of data, and
all that data is of the same type, I recommend storing it in a 5000-by-8
matrix instead of an 8 element cell array. Cell arrays are very general (the
contents of the cells can be anything -- numbers, strings, objects, function
handles, etc.) and so there are some operations that aren't defined for them
that are defined for regular numeric matrices.

> Now I want to compare the runs to each other. Compare say sample 5 of run
> 1 with sample 5 of run 2, 3, 4, 5, 6, 7 and 8. I want to calculate
> standard deviation and maybe some other statistical parameter (I'm not
> exactly clear about this yet). But in short i want to be able to compare
> the runs to each other, and maybe find and "average run".

If you have your data in a matrix, many of the data analysis functions
accept a dimension input argument to specify the dimension over which to
operate. For instance:

>> A = [1 2 3 4; 5 6 7 8; 9 10 11 12];
>> sum(A, 1) % Sum the values in each column
ans =
    15 18 21 24

>> sum(A, 2) % Sum the values in each row
ans =
    10
    26
    42

>> sum(A(:)) % Turn A into a vector and sum all its elements
ans =
    78

> How do I go about this? The std function returns the standard deviation of
> a vector, meaning I'd get the standard deviation of ONE run, not the runs
> compared to each other.

The STD function is one of those functions that accepts a dimension input
argument so you could get the standard deviation of each row or each column.
[Two others that may be of use to you are MEAN and MEDIAN, since you're
looking for an "average run."]

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Viewing all articles
Browse latest Browse all 22

Trending Articles