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???

 采纳的回答

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

1 个评论

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

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Function Creation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by