How to introduce a time-shift into data?
显示 更早的评论
Dear Community!
I would like to introduce a time shift to my data. The goal is that the lower figure in the subplot gets a time shift of 4 ms.
Here is my code:
% time steps
DTms = 0.01; % [ms] time step -- 100kHz sampling rate
% time lengths
Tall = 2000; % [ms] entire duration of simulation
Tinit = 500; % [ms] starting time of stimulus
Tstim = 1000; % [ms] duration of entire stimulus
Tlast = 500; % [ms] time after stimulus
Nall = round(Tall /DTms);
Ninit = round(Tinit/DTms);
Nstim = round(Tstim/DTms);
Nlast = round(Tlast/DTms);
tvms = (0:Nall-1)*DTms-Tinit; % time vector (stimulus starts at time zero)
lmain = logical( [zeros(1,Ninit),ones(1,Nstim),zeros(1,Nlast)] );
tvmain = tvms(lmain);
fs = 1e5; % 100 [kHz] sampling rate
%% Here is now a part you don't have acces to, but i believe its not important
fibres_ipsi = zeros(25,length(lmain));
for i = 1:25
% Put all spikes of each row in one column vector;
fibres_ipsi (i,:) = ANout_ipsi (1,:,i);
end
fibres_contra = zeros(10,length(lmain));
for i = 1:10
% Put all spikes of each row in one column vector;
fibres_contra (i,:) = ANout_contra (1,:,i);
end
input_ipsi = sum(fibres_ipsi);
input_contra = sum(fibres_contra);
subplot(2,1,1)
plot(tvms, input_ipsi)
xlim([0 100])
subplot(2,1,2)
plot(tvms,input_contra)
xlim([0 100])
ITD = 4;
samples_per_itd = fs/ITD;
% Apply ITDs
spikes_indices = find(input_ipsi >= 1); % Get indices
spike_times = tvms(spikes_indices); % Get spike times
spike_time_ITD = spike_times + (ITD); % Apply ITD

The lower subplot datapoint should move to the right!
Thank you in advance,
Paul
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Dates and Time 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!