Code covered by the BSD License  

Highlights from
matlab2fmex

image thumbnail

matlab2fmex

by

 

03 Feb 2004 (Updated )

matlab2fmex.m is a small translator which aims to convert numerical M-files to Fortran90 mex.

Editor's Notes:

This author's upload was somehow corrupted. We fixed this on March 29, 2006. At that time, we also converted it from a GZ file a ZIP file for better cross platform portability.

[out,outLoc]=findBefore(strIn,loc,strToFind)
function [out,outLoc]=findBefore(strIn,loc,strToFind)
%returns character and location for preceding character,
%or for preceding strToFind
%  if none, then out='', outLoc=-1

out='';
outLoc=-1;
if loc<2
 return
end

if nargin<3
 fthere=find(~isspace(strIn));
 fthereBefore=fthere(fthere<loc);
 if ~isempty(fthereBefore)
  out=strIn(fthereBefore(end));
  outLoc=fthereBefore(end);
 end % if ~isempty(fthereBefore)
else
 fthere=find(strIn==strToFind);
 fthereBefore=fthere(fthere<loc);
 if ~isempty(fthereBefore)
  out=strIn(fthereBefore(end));
  outLoc=fthereBefore(end);
 end % if ~isempty(fthereBefore)
end

Contact us