Symbolic Subs Function isn't picking up formula

5 ビュー (過去 30 日間)
Mauricio Medaets
Mauricio Medaets 2020 年 5 月 24 日
回答済み: Sai Sri Pathuri 2020 年 5 月 27 日
This is pretty strightforward:
I define a generic symbolic function, say theta(t), then later in the code I want to define the actual formula of theta(t) being, let's say, t^2.
And I need a means of substituting (or "updating") wherever I referenced theta(t) with t^2, which I assume the subs function is designed for and should do automatically.
Please let me know what am I missing or what other function to use.
Thanks
syms t theta(t)
a(t) = t*theta(t)
theta(t) = t^2
subs(a)
% which gives me:
ans(t) = t*theta(t) % BUT IT SHOULD BE t^3 !!!

回答 (1 件)

Sai Sri Pathuri
Sai Sri Pathuri 2020 年 5 月 27 日
In your code, both a and thetha are functions of t. When you use subs function, the value of t will be substituted. Hence you are getting the above answer. You may use following code to obtain desired answer
syms t theta
a(t) = t*theta
theta = t^2
subs(a)

カテゴリ

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

製品


リリース

R2014b

Community Treasure Hunt

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

Start Hunting!

Translated by