Hi, Well as my question says, i need help to make groups of data for every 2 changes of sign, for example i have this data:

` 0.1 -0.16966 0.2 -0.072523 0.3 0.21066 0.4 -0.06312 0.5 -0.14626 0.6 0.14327 0.7 0.010853`

And i want a code that make me this following groups:

` Group 1: -0.16966, -0.072523, 0.21066 Group 2: -0.06312, -0.14626, 0.14327, 0.010853`

And then, find the max and min for each group, add them, find the average of all group:

` G=matrix with all the groups a=max(G) b=min(G) A=mean(a+abs(b))`

I have done a code which makes this but in order to work i need to put Zeros value in between of a change of sign and i have like 300 points so it takes time,

the code that i have right now is:

` clear all close all %--------------------------OPTIMIZATION OF TMD----------------------------%`

%Load files%

for u = 0:20:220; C= strcat('TMD_',num2str(u),'.csv'); load(C); end %------C=0 N*s/m------%

c0=0; t0=TMD_0(:,2); %seconds%

vy0=TMD_0(:,3); %m/s%

allzeros = find(vy0 == 0); x0 = allzeros(1:2:end); z0 = zeros(length(x0),1); a0 = zeros(length(x0),1); for i=1:length(x0)-1 y0 = vy0(x0(i):1:x0(i+1)); z0(i) = max(y0);a0(i) = min(y0); end yend0 = vy0(x0(end-1):1:x0(end)); z0(length(x0)) = max(yend0); a(length(x0)) = min(yend0); B0 = z0+abs(a0); A0 = mean(B0);

Thanks for the ideas!

## Best Answer