From: Matt Fig on
"us " <us(a)neurol.unizh.ch> wrote in message <i00cef$obk$1(a)fred.mathworks.com>...
> one of the many solutions
>
> % the data
> m=[
> 36 66 21 65 52 67 73
> 31 23 19 33 36 39 42
> ];
> v=[40 38 39 40 35 32 37];
> iv=[
> 20 40
> 40 60
> 60 80
> ];
> % the engine
> [ix,ix]=arrayfun(@(x,y) histc(m(1,:),x:y),iv(:,1),iv(:,2),'uni',false);
> r=cellfun(@(x) [m(:,x~=0);v(x~=0)],ix,'uni',false);
> % the result
> % - note: each CELL combines your two outputs; simply take them apart if necessary
> r{1}
> %{
> 36 21 % <- HT_T_1 row 1
> 31 19 % <- HT_T_1 row 2
> 40 39 % <- P_1
> %}
>
> us


Wow, us. You are clever indeed. I can't make heads or tails of what the OP wants. He says the first array should contain all values between 20 and 40, yet his result does not include 23 and does include 19! The second array is supposed to contain values between 40 and 60, yet includes 36! And where is the requirements for P listed at all? My hat's off to you!