Using matlabFunction

I wish to use matlabFunction to convert symbolic expressions into m-files. However, I can't even make the examples given on http://www.mathworks.com/help/toolbox/symbolic/matlabfunction.html work.
For example, if I type in the following command in Matlab (as copied from the above webpage):
syms x y z; r = x^2 + y^2 + z^2; f = matlabFunction(log(r)+r^(-1/2),'file','myfile');
then Matlab returns the following error message:
??? Error using ==> dataread Too many input arguments.
Error in ==> strread at 57 [varargout{1:nlhs}]=dataread('string',varargin{:},'bufsize',2*num );
Error in ==> ver at 69 p = strread(matlabpath,'%s','delimiter',[pathsep '\n']);
Error in ==> sym.matlabFunction>writeHeader at 386 symver = ver('symbolic');
Error in ==> sym.matlabFunction>writeMATLAB at 359 writeHeader(fid,fname,varnames,outnames);
Error in ==> sym.matlabFunction at 117 g = writeMATLAB(funs,file,varnames,outputs,body);
What's wrong???

 Accepted Answer

Please try
which -all dataread
as it is possible that somehow you have your own function named dataread

1 Comment

Thanks a lot, Walter! That was indeed the problem. After renaming "my own" dataread.m file, 'matlabFunction' now works as a charm.

Sign in to comment.

More Answers (0)

Categories

Find more on Function Creation in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!