⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 truncatenan.m

📁 Continuous Profile Models (CPM) Matlab Toolbox.
💻 M
字号:
function [dat newBounds] = truncateNAN(dat)%% remove the beginning and ends, if there is any single%% sample that doesn't have 'stuff' there.%% add them all up so that nans collapsetemp2 = dat{1};for jj=2:length(dat)    temp2=temp2 + dat{jj};endif size(dat{1},2)>1    hasNoStuff = any(temp2');else    hasNoStuff=isnan(temp2);endbreakPt = find(diff(hasNoStuff));%% case for when it goes right to end for all tracesif length(breakPt)==2    newBounds = [breakPt(1)+1, breakPt(2)-1];elseif length(breakPt)==1    newBounds = [breakPt(1)+1, size(temp2,1)];else    error('shouldt be here');endnewRg = newBounds(1):newBounds(2);for jj=1:length(dat)    %disp(['truncating ' num2str(jj)]);    temp = dat{jj};    dat{jj}=temp(newRg,:);endfor jj=1:length(dat)    temp = dat{jj};    if any(isnan(temp(:)))        error('still has a NaN');    endendreturn;%% this causes memory problemstemp = mycell2mat(dat);%temp = cell2mat(dat);temp2 = squeeze(sum(temp,2))==0;hasNoStuff = any(temp2');breakPt = find(diff(hasNoStuff));newBounds = [breakPt(1)+1, breakPt(2)-1];newRg = newBounds(1):newBounds(2);temp = temp(newRg,:,:);for jj=1:size(temp,3)    dat{jj}=temp(:,:,jj);end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -