Code covered by the BSD License  

Highlights from
matlab2fmex

image thumbnail
from matlab2fmex by Ben Barrowes
matlab2fmex.m is a small translator which aims to convert numerical M-files to Fortran90 mex.

out=findlefts(locs,str)
function out=findlefts(locs,str)
closestr=str(locs(1));
switch closestr
 case ')'
  openstr='(';
 case ']'
  openstr='[';
 case '}'
  openstr='{';
end
for i=1:length(locs)
 left=0;right=1;
 count=1;
 while left~=right
  if str(locs(i)-count)==openstr, left=left+1; end
  if str(locs(i)-count)==closestr, right=right+1; end
  count=count+1;
 end
 out(i)=locs(i)-(count-1);
end

Contact us at files@mathworks.com