Code covered by the BSD License  

Highlights from
f2matlab

f2matlab

by

 

16 Jun 2004 (Updated )

Converts basic fortran90 source code to MATLAB source code.

out=findlefts_f(locs,str)
function out=findlefts_f(locs,str)
closestr=str(locs(1));
switch closestr
 case ')'
  openstr='(';
 case ']'
  openstr='[';
 case '}'
  openstr='{';
end
l=(str==openstr);    r=(str==closestr);
both=l-r;            c=cumsum(both);
fc=[fliplr(c) 0];
for i=1:length(locs)
 floc=length(str)-locs(i)+1;
 found=find(fc==(fc(floc)));
 found=found(found>floc+1);
 out(i)=length(str)-found(1)+1+1;
end

Contact us