MATLAB eval() function error
eval() returns the same error, even with the simplest of inputs.
>> ns=int2str(17)
>> xs=num2str(18)
>> d = eval(ns,'+',xs)
??? Index exce开发者_开发百科eds matrix dimensions.
>> eval('1/2')
??? Index exceeds matrix dimensions.
Any help would be appreciated.
try clear all
first.. it seems you have a variable called eval
that is shadowing the function.
>> eval = 1;
>> which -all eval
eval is a variable.
built-in (C:\Program Files\MATLAB\R2010a\toolbox\matlab\lang\@char\eval) % Shadowed char method
C:\Program Files\MATLAB\R2010a\toolbox\matlab\lang\@opaque\eval.m % Shadowed opaque method
C:\Program Files\MATLAB\R2010a\toolbox\stats\@classregtree\eval.m % Shadowed classregtree method
I think you need to put the argument in square brackets. That's the syntax shown in the documentation - see http://www.math.ufl.edu/help/matlab/tec1.3.html or http://www.mathworks.com/access/helpdesk/help/techdoc/ref/eval.html
I don't have matlab, but in freemat,
--> ns='12'
ns =
12
--> xs='14'
xs =
14
--> d=eval([ns,'+',xs])
d =
26
--> d
ans =
26
--> d=eval(ns,'+',xs)
Error: Too many inputs to function eval
精彩评论