How to run equation only in one script as a function by strategically locating "syms x'? (Note: Except using @x)

2 ビュー (過去 30 日間)

回答 (1 件)

Ashutosh Singh Baghel
Ashutosh Singh Baghel 2021 年 12 月 22 日
編集済み: Ashutosh Singh Baghel 2021 年 12 月 22 日
Hi Jims,
I understand you wish to implement an equation inside a function defined in the same script calling it. This issue is resolved by adding two numbers, as shown in the following example.
a = 2;
b = 4;
[sum_0,sum_1] = sumEquation(a,b)
sum_0 = 
6
sum_1 = 
6
function [OUT1,OUT2] = sumEquation(x_in,y_in)
syms f(x,y)
f(x,y) = x + y;
OUT1 = f(x_in,y_in);
OUT2 = summation(x_in,y_in);
end
function out = summation(x1,y1)
syms g(x,y)
g(x,y) = x+y;
out = g(x1,y1);
end
For more information, visit MATLAB Documentation page on 'syms'.

カテゴリ

Help Center および File ExchangeLinear Algebra についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by