Why do I get a numerical value when I use syms?

1 回表示 (過去 30 日間)
Ekaterina Wiktorski
Ekaterina Wiktorski 2016 年 4 月 12 日
編集済み: Walter Roberson 2016 年 4 月 12 日
In a function body I have following expressions:
syms eps
Fi=1/(1+fi);
N_theta1=Fi/le*(6*eps-6*eps^2);
where le and fi were specified as inputs to the function.
Later I want to integrate a function, containing N_theta1 (which depends on eps, which is symbolic), with respect to eps. I get an error "Undefined function 'int' for input arguments of type 'double'." because N_theta1 has a numerical value! I cannot understand why. In the Workspace eps is defined as symbolic 1x1 value...Any idea?

回答 (1 件)

Steven Lord
Steven Lord 2016 年 4 月 12 日
編集済み: Steven Lord 2016 年 4 月 12 日
You're "poofing" a variable named eps into the workspace at runtime, but when MATLAB parsed the file there was no sign that eps was going to be a variable so it "decided" eps was the eps function. To solve this, assign "eps = 0;" prior to your syms call, use eps = sym('eps'); instead of syms, or use a different variable name.

カテゴリ

Help Center および File ExchangeSymbolic Math Toolbox についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by