Substituting and evaluating function

6 次查看(过去 30 天)
I have attempted to substitute the X variable into my function and evaluate it. This is the result. If it is not possible please tell me and I will find a difference method?
>> subs der(140,x);
Warning: Support of character vectors that are not valid variable names or define
a number will be removed in a future release. To create symbolic expressions,
first create symbolic variables and then use operations on them.
> In sym>convertExpression (line 1586)
In sym>convertChar (line 1491)
In sym>tomupad (line 1243)
In sym (line 199)
In subs (line 66)
>> eval der
der =
(13459*cos((313*x)/200 - 1689/2000))/25 + (42471*cos((1573*x)/1000 + 1153/500))/80 + (937443*cos((1849*x)/2500 + 441/250))/62500
GS.
  2 个评论
Stephen23
Stephen23 2017-9-13
What is der? Is it symbolic, or is it a simple function handle?
Gavin Seddon
Gavin Seddon 2017-9-13
Hello, der is the symbolic function that is the result of dIff fx.

请先登录,再进行评论。

采纳的回答

Star Strider
Star Strider 2017-9-13
Try this (in R2012a and later):
syms x
X = sym(140);
der(x) = (13459*cos((313*x)/200 - 1689/2000))/25 + (42471*cos((1573*x)/1000 + 1153/500))/80 + (937443*cos((1849*x)/2500 + 441/250))/62500;
Desired_Symbolic_Result = der(X)
Desired_Numeric_Result = vpa(der(X))
Desired_Symbolic_Result =
(937443*cos(26327/250))/62500 + (42471*cos(111263/500))/80 + (13459*cos(436511/2000))/25
Desired_Numeric_Result =
-503.67380291547475440432522297924
Beginning in R2012a, you can create symbolic functions. You then work with them as you would any other function.
  24 个评论
Gavin Seddon
Gavin Seddon 2017-11-13
Hello, this is really trivial however histogram(X) does not use my values. So how do I instruct Matlab to use my X and Y values? GS.
Star Strider
Star Strider 2017-11-13
The documentation provides guidance:
histogram(X,edgvct)
or if you have two arrays and you want a 2-dimensional histogram, use the histogram2 function. You may have to provide a second vector of edges for the ‘Y’ data as well. See the documentation for details.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Whos 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by