f



Forcing Matlab to run .m file when a mex file is present

I am creating an environment to test mex files which will replace
exisiting m files in an extensive matlab simulation. As I do this I
want to be able to check that the results from the new mex function
are the same as the result from the existing m file function. Is
there a slick way to force Matlab to call the m file function when a
mex function of the same name exists? Ideally I would want to do
something like:

a = my_function(x,y,z) % calls the mex version
b = my_function(x,y,z) % calls the m file version
error = abs(a-b);

Any suggestions that don't require renaming files?

Thanks a lot
Dan
0
2/22/2005 11:43:31 PM
comp.soft-sys.matlab 211266 articles. 24 followers. lunamoonmoon (257) is leader. Post Follow

1 Replies
701 Views

Similar Articles

[PageSpeed] 49

Dan Macumber:
<SNIP wants to compare perf of funcs with equal names...

one of the many solutions (r14+)

% put mex-files into
% .../mex
% and m-files inot
% .../m
% assume foo.m/foo.dll

     fnam='foo'; % NO extension!
     pmex='your_full_mex_path';
     pm='your_full_m_path';
     opw=cd(pmex);
     f1=str2func(fnam);
     cd(pm);
     f2=str2func(fnam);
     cd(opw);
% test
     functions(f1)
     functions(f2)
% -and- run
     r1=f1(a,b,c)
     r2=f2(a,b,c)
     e=r1-r2

us
0
us1 (8051)
2/23/2005 12:17:07 AM
Reply: