cellmat.m (440B)
1 % cellmat.m function y=cellmat(a,endchar); 2 % 3 % Accepts a 1xN string of variable names, separated by spaces, and creates 4 % a cell matrix with each variable on a different row. 5 6 function y=cellmat(a,endchar); 7 8 if exist('endchar')~=1; endchar=' '; end; 9 10 y={}; 11 start=1; 12 M=length(a); 13 if a(M)~=endchar; a=[a endchar]; end; 14 N=1; 15 16 for i=1:length(a); 17 if a(i)==endchar; 18 ypc=a(start:(i-1)); 19 y{end+1}=ypc; 20 start=i+1; 21 end; 22 end; 23 y=y';