Hi,
I have data of ~3500×2. I want to calulate mean of second column for a particular condition in first column using 'while'.
let data (a, b) be like
0.5 1.8
0.6 1.5
0.9 1.8
1.0 1.5
1.1 1.4
1.2 1.4
1.5 1.6
1.8 1.2
2.1 1.2
2.3 1.3
2.4 1.5
2.6 1.8
2.9 2.0
3.0 3.0
3.12 3.2
3.15 1.9
3.16 1.7
3.18 2.2
I need to calculate mean of b, if a> 0.5 and a<1.5. Then increase 'a' by 1 and calculate mean of b (i.e for a > 1.5 and a<2.5) and so on. It may be a silly question but I am stuck with it. My code is
del=0.5;k=1;a(k)=1;while(a(k) >(a(k)-del) && a(k)< (a(k)+del))xn(k)=mean(b(k)); k= k+1;a(k)=a(k)+1;endbut it shows error Index exceeds array bounds.Error in untitled (line 12)a(k)=a(k)+1;Thank you for your help.
Best Answer