subtract an average value from a range
    6 views (last 30 days)
  
       Show older comments
    
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 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.
Answers (0)
See Also
Categories
				Find more on Resizing and Reshaping Matrices in Help Center and File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
