フィルターのクリア

how to replace a symbolic variable with a real one after computation?

9 ビュー (過去 30 日間)
Syed Yasir Azeem
Syed Yasir Azeem 2022 年 10 月 13 日
コメント済み: Paul 2022 年 10 月 13 日
I have supposed to variable as symbolic and after some calculation I want to remove those symbolic variables and replace them with other real variable to that the output can be calculated for those real variables. Attached is the problem:
Here after syms I3 and I4. I applied some operators to a which is composed of symbolic varaibles I3 and I4. to the end I get symbolic variable d which is like "xyz * I3 - abc" here I want to create a new variable z which is composed of d but the it shouldn't be symbolic and I3 has to be replaced by I5(real variable). I have tried to alot but couldn't find the accurate solution to my problem. Many thanks

採用された回答

Paul
Paul 2022 年 10 月 13 日
Use subs or symfun objects and covert to double are two options
syms I3 I4
d = I3 + I4;
double(subs(d,[I3 I4],[1.1 2.2]))
ans = 3.3000
d(I3,I4) = I3 + I4;
double(d(1.1,2.2))
ans = 3.3000

その他の回答 (1 件)

Bjorn Gustavsson
Bjorn Gustavsson 2022 年 10 月 13 日
Perhaps straight conversion of the symbolic expressions to functions (function-handles, dynamical functions) with the matlabFunction-function:
d_fcn = matlabFunction(d)
Since you presented your code as an image it is impossible for me to check that this actually returns a function with all the input-parameters you want - without typing in your code from that image, and that's not going to happen. Hopefully you can adapt or use this solution. That function will allow you to plug in whatever values you want for the different input parameters.
HTH
  5 件のコメント
Bjorn Gustavsson
Bjorn Gustavsson 2022 年 10 月 13 日
So something like: damned if you do or cursed if you don't? Drowning in a half-full glass, or dehydration in a half-empty glass?
Paul
Paul 2022 年 10 月 13 日
Well, I wouldn't go so far as to being damned and cursed. How could such things ever occur when using Matlab? :)

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeConversion Between Symbolic and Numeric についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by