"Sean " <sean.dewolski@nospamplease.umit.maine.edu> wrote in message <i6rcns$dip$1@fred.mathworks.com>...
> "Kostas " <kfragkos@gmail.com> wrote in message <i6rb76$3dj$1@fred.mathworks.com>...
> > dpb <none@non.net> wrote in message <i6r8lc$ac1$1@news.eternalseptember.org>...
> > > Kostas wrote:
> > > > Hello, i need your help for calculating the mean value of the group of
> > > > measurements. More specific a measurement with the instrument i work
> > > > consists of 5 repetition and i want to calculate the mean value of those
> > > > 5 repetitions, standard deviation etc. Next few lines indicated an
> > > > example of my data
> > > >
> > > > gr gn t0 mu par1 par2
> > > > fil t1 dt
> > > > 3 2 467.89 3.1825 255.67 4.3011 0 8 42
> > > > 3 3 468.52 3.1711 256.24 1.9434 0 8 42
> > > > 3 4 469.14 3.16 268.22 1.8474 0 8 42
> > > > 3 5 469.77 3.1488 274.77 1.8181 0 8 42
> > > > 4 1 471.47 3.1192 273.92 1.6576 0 8 42
> > > > 4 2 472.09 3.1086 273.86 0.51999 0 8 42
> > > ...
> > >
> > > > The problem is that for further data analysis or plots i need to use
> > > > other software packages, so i was wondering if someone could be kind
> > > > enough to help me create a matlab script, so as to do my whole analysis
> > > > in matlab. Thanks in advance
> > >
> > > In general, "no"...c.ss.m respondents will bend over backwards often to
> > > help but rarely actually write solutions w/o the requestor showing what
> > > efforts they've made on their own...
> > >
> > > So, in that vein,
> > >
> > > Begin by reading the "Getting Started" tutorial information in the
> > > online documentation  it doesn't take long to begin to get a feel for
> > > how Matlab works.
> > >
> > > Once you've got that, following specifics may be of benefit...
> > >
> > > Your data is pretty regular, look at
> > >
> > > doc textscan
> > >
> > > or the import wizard for getting the data into Matlab for working on.
> > >
> > > doc mean
> > > doc std
> > >
> > > will give you the tools for the computations.
> > >
> > > doc unique
> > >
> > > and reading on logical addressing will provide some ideas on how to
> > > segregate the data by measurement group.
> > >
> > > Good luck; feel free to post specific questions (show your work) as you
> > > progress...
> > >
> > > 
> >
> > Thank you for your reply. I totally agree with your opinion/way of thinking. To be honestly i have a very little matlab experience, like i said before i use it mostly for doing plots. To insert the data isn't a problem for me, actually is pretty easy
> >
> > filename=['myfile.dat'];
> > fid=fopen(filename);
> > data=fscanf(fid,'%g %g',[9 inf]);
> >
> > my main problem is to "think" a "logical" condition so as to do my calculations under this specific condition, possible because i have learn programming in a very different way than the matlab (i guess, you can understand have a look in my code).
> >
> > So the values column data(:,2) ranges from 1 to 5 and while column data(:,1) is increasing. What i was thinking is that i could go through a for loop into the whole matrix
> >
> > for i=1:size(data,2)
> > n=n+1;par1=data(:,i);
> > if data(i,2)=5
> > mval=mean(par1);std1=std(par1);
> > fwrite(results....);
> > n=0;par1=zeros(5,1);
> > end
> > end
> >
> > but i think this isn't the most efficient way for programming in matlab and moreover i would like to get more familiar with the matlab way and get ideas.
>
> I can't really interpret what you're trying to do.
> Since you clearly care about data in the second column == 5 why don't you find those first and then operate only on the (rows?) that contain it? Once again, the description is vague and the sample code is impossible to interpret. I tried, and couldn't wrap my head around what you were trying to do.
>
> rows = find(data(:,2) ==5);
> for ii = 1:numel(rows);
> results = calculate_your_results(data(rows(ii),:))
> fprintf(results)
> end
Sean, first of all i would like to apologize for my bad English. i 'll try to explain a little better what i want to do giving an example
3 1 467.47 3.1192 273.92 1.6576 0 8 42
3 2 467.89 3.1825 255.67 4.3011 0 8 42
3 3 468.52 3.1711 256.24 1.9434 0 8 42
3 4 469.14 3.16 268.22 1.8474 0 8 42
3 5 469.77 3.1488 274.77 1.8181 0 8 42
4 1 471.47 3.1192 273.92 1.6576 0 8 42
if you see while the first column is 3 second takes values from 1 to 5 (so like this there is a "group" of 5 values for the index 3), after first column take the value 4 and second again from 1 to 5 (then a "group" for the index 4) and so on. What i want to do is to calculate the mean value let's say of the 5th column while the value of the first is steady (the mean value of each group).
eg while first column = 3, average = (273.92+255.67 +256.24+268.22+274.77)/5=....
when first column = 4, average=(a1+a2+a3+a4+a5)/5 and so on.
Hope this is little more clear.
