Error using / Arguments must be numeric, char, or logical. what should I do I tried but did not seem to work?
12 次查看(过去 30 天)
显示 更早的评论
>> m=2+0
m =
2
>> n=2+5
n =
7
>> syms x
>> f=inline(2*x^2-(3*m-n)*x-m*n)/(x^2+(m-n)*x-n*m)
Error using /
Arguments must be numeric, char, or logical.
0 个评论
回答(2 个)
Chandler Hall
2022-11-13
编辑:Chandler Hall
2022-11-13
To create a symbolic function, you must first declare it via the syms function, and then define its content. The syntax for this is straightforward but atypical:
m = 2; n = 7;
syms f(x)
f(x) = (2*x^2-(3*m-n)*x-m*n)/(x^2+(m-n)*x-n*m);
1 个评论
Walter Roberson
2022-11-13
This is not correct. You can create a symbolic function in three different ways:
syms Name(Variable list)
Name(Variable list) = symbolic expression
Name = symfun(symbolic expression, Variable list)
The syms form has the side effect of defining the variables, but is not required before either of the other approaches.
Walter Roberson
2022-11-13
Never inline() a symbolic expression, it is not defined. matlabFunction() instead.
Never eval() a symbolic expression either, use subs()
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Numbers and Precision 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!