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

 Réponse acceptée

Walter Roberson
Walter Roberson le 14 Juil 2011

0 votes

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

1 commentaire

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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Function Creation dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by