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

📄 mat2col.m

📁 JLAB is a set of Matlab functions I have written or co-written over the past fifteen years for the p
💻 M
字号:
function[varargout]=mat2col(varargin)%MAT2COL  Compress NAN-padded matrix data into long columns.%%   C=MAT2COL(M), where the columns of matrix M are data vectors of%   nonuniform length with NANs filling out the gaps in each column,%   appends together all the columns into a vector C in which isolated%   NANs mark the transitions between columns.%%   [C1,C2,...]=MAT2COL(M1,M2,...) also works for multiple input %   matrices of the same size.  In this case the locations of NANs in %   M1 are used as the key for appending all the MI into columns.  %  %   MAT2COL, COL2MAT, and COLBREAKS together form a system for moving%   data with segments of nonuniform length rapidly back and forth%   between a column format and a padded-matrix format. CTD or float%   data, for instance, can be stored in the (usually much smaller)%   column format and converted into the matrix format upon loading.%%   MAT2COL(M1,M2,...); with no output arguments overwrites the%   original input variables.%%   See also COL2MAT, COLBREAKS%   _________________________________________________________________%   This is part of JLAB --- type 'help jlab' for more information%   (C) 2000, 2004 J.M. Lilly --- type 'help jlab_license' for details          %no loops!if strcmp(varargin{1},'--t')returnendi=0;while i<nargin	i=i+1;	mat=varargin{i};	if i==1		if ~all(isnan(mat(end,:)))			mat(size(mat,1)+1,:)=nan*ones(size(mat(1,:)));		end		mat=mat(:);		%new matrix should include all data points		bool=zeros(size(mat));		index=find(~isnan(mat));		bool(index)=ones(size(index));		index2=find(diff([bool;0])==-1)+1;		if ~isempty(index2)			bool(index2)=ones(size(index2));		end		index=find(bool);	end	mat=mat(index);	col=mat;	varargout{i}=col;endif nargout>nargin        varargout{end+1}=index;	%eval(['c' int2str(nargout) '=index;']);endif nargout==0   %for i=1:nargin   %   eval(['varargout{',int2str(i),'}=c',int2str(i),';'])   %end    eval(to_overwrite(nargin));end

⌨️ 快捷键说明

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