Symbolic evaluation with value

105 ビュー (過去 30 日間)
Bert
Bert 2022 年 11 月 22 日
編集済み: Rishav 2023 年 9 月 5 日
In a lecture I had my tutor showed us how to evalute a symbolic equation that he had made but with a value for the symbolic variable (just 1 symbolic variable in the equation), he then put it into a graph to display but the original equation was in symbolic form. Does anyone know what that function is as I can't find it for the life of me. It wasn't subs, also looking for this specific function as its relative to my current equation.
  1 件のコメント
Torsten
Torsten 2022 年 11 月 22 日
To substitute numerical values for symbolic variables, use "subs".
To transform a symbolic function to a numeric function handle, use "MatlabFunction".

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

採用された回答

Rishav
Rishav 2023 年 9 月 4 日
編集済み: Rishav 2023 年 9 月 5 日
Hi Bert,
  • "subs" is used to substitute numerical values for symbolic variables.
Here is an example on how to use 'subs':
% Define a symbolic variable x
syms x;
% Define a symbolic equation
eq = x^3 + 4*x + 1;
% Substitute a specific value for x
x_value = 2;
result = subs(eq, x, x_value);
% Display the result
disp(result);
  • "matlabFunction" is used to transform a symbolic function to a numeric function handle.
Here is an example on how to use 'matlabFunction':
% Define symbolic variables
syms x y;
% Define a symbolic expression
f = x^2 + y^2;
% Create a numeric function handle
numeric_function = matlabFunction(f, 'Vars', [x, y]);
% Now you can use the numeric_function to evaluate the expression numerically
x_value = 3;
y_value = 4;
result = numeric_function(x_value, y_value);
% Display the result
disp(result);

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by