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

 Akzeptierte Antwort

Walter Roberson
Walter Roberson am 14 Jul. 2011

0 Stimmen

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

1 Kommentar

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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Function Creation finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by