countdlm.m

来自「细胞生长结构可视化工具箱-MATLAB Toolbox1999.zip」· M 代码 · 共 32 行

M
32
字号
% function count = countdlm(filename,dlm)
%
% Counts number of delimetrs on first line

function count = countdlm(filename,dlm)

eol = 10;

count=0;

file = fopen(filename);
if file ~= -1
	l = fgets(file);	% Obtain entire string of labels
	
	ie=1;			% end index of current string

	finished = 0;		% flag to detect when end of line is reached	
	while(finished == 0) 
	
		while (l(ie) ~= dlm) & (l(ie) ~= eol)	% find next delimeter
			ie = ie+1;
      end	
      if l(ie)==dlm
         count = count+1;
      end
      if l(ie)==eol
         finished = 1;
      end
      ie=ie+1;
   end
end

⌨️ 快捷键说明

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