subtract an average value from a range

1 次查看(过去 30 天)
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:
fileread = csvread('Data190409_224329trial_rec_data.csv');
subdat1=reshape(fileread,[3000 length(fileread)/3000]); %array to matrix conversion
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 个评论
Rik
Rik 2019-4-18
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.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

产品


版本

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by