# subtract an average value from a range

1 view (last 30 days)
Muhammad Haziq on 18 Apr 2019
Commented: Rik on 18 Apr 2019
Hi,
I have a matrix of 3000x6000. Also I have some values which I treated as nose_pokes. From every nose poke value I want two things.
1) 50 columns before nose poke I want to add them and then take an average of them which in result give me a matrix of 3000x1(which becomes base line of my signal).
2) After each nose poke I have to take 100 columns and subtract the baseline from all columns one by one and rest of the data remains same.
I write down some code but I am unable to perform this task can any body help me.
I want to upload file but its too big I can't upload. code:
for ki= 1:1:(size(nose_pok,2)-1)
qw1=nose_pok(ki)-80;
qw2=nose_pok(ki)-40;
base_rec_range = subdat1(:,qw1:qw2);
range=size(base_rec_range,2);
sum=0
for m=1:1:range
sum = sum + base_rec_range(:,m);
end
base_rec=sum/range;
for index = 1:length(nose_pok)
data_reshaped(:,nose_pok(index):nose_pok(index)+100)=subdat1(:,nose_pok(index):nose_pok(index)+100)-base_rec(:,1);
end
end

#### 1 Comment

Rik on 18 Apr 2019
Can you write a small example input and output pair? I have the feeling this should be relatively straightforward, but I am unsure what exactly you mean.