Substituting and evaluating function

5 ビュー (過去 30 日間)
Gavin Seddon
Gavin Seddon 2017 年 9 月 13 日
コメント済み: Star Strider 2017 年 11 月 13 日
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 Center および File ExchangeWhos についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by