📄 getnewtrace.m
字号:
%function newTrace =% getNewTrace(samples,scaleAndTimes,currentTrace,G)%% After Viterbi-alligning all the samples to the currentTrace,% update the latent trace, by averaging, and smoothing.function endTrace = getNewTrace(samples,scaleAndTimes,currentTrace,G)newTrace = zeros(size(currentTrace));%keep track of how many samples have an entry at each fake time pointtraceCounts = newTrace;numSamples = length(samples);%% Averagefor ii=1:numSamples st = scaleAndTimes{ii}; newTrace(st(:,2)) = newTrace(st(:,2)) +... samples{ii}.*2.^(G.scales(st(:,1))); traceCounts(st(:,2)) = traceCounts(st(:,2)) + 1;endnotZero = find(traceCounts);newTrace(notZero) = newTrace(notZero)./traceCounts(notZero);% Interpolate for places with zero countsisZero = setdiff(1:length(traceCounts),notZero);interpPts = interp1q(notZero',newTrace(notZero)',isZero');newTrace(isZero)=interpPts;% interp1q returns NaN for pts that need to be extrapolated% let's deal with these by setting them to the minimum valuenewTrace(isnan(newTrace))=min(newTrace);% Smoothmyfilt = [1 1 1 1 1];myfilt = myfilt/sum(myfilt);smoothTrace = rconv2(newTrace,myfilt);% figure, subplot(2,1,1),plot(newTrace,'k+'); subplot(2,1,2),plot(smoothTrace,'r*');endTrace = smoothTrace;%endTrace = newTrace;%figure, plot(currentTrace,'k+'); hold on; plot(newTrace,'r^');%figure, plot(traceCounts,'+');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -