Assumption on another symbolic Variable affecting a previous assumption

1 回表示 (過去 30 日間)
Why is the assumption I made being changed by the next assumption I do on another variable ?
The assumpitons on Phi_geod and Phi_dot_geod are being changed by the assumptions on the variables lambda_geod and lambda_dot_geod.
Code:
syms Phi_geod(t) lambda_geod(t)
syms Phi_dot_geod(t) lambda_dot_geod(t)
assumptions(Phi_geod)
ans = Empty sym: 1-by-0
assume(Phi_geod(t),"real");
assumptions(Phi_geod)
ans = 
assume(lambda_geod(t),"real");
assumptions(Phi_geod)
ans = 
assume(Phi_dot_geod(t),"real");
assume(lambda_dot_geod(t),"real");
assumptions(Phi_geod)
ans = 

採用された回答

Dyuman Joshi
Dyuman Joshi 2024 年 4 月 4 日
Because assume over-writes assumptions.
From the Tips section in the documentation page -
"assume removes any assumptions previously set on the symbolic variables. To retain previous assumptions while adding an assumption, use assumeAlso."
As mentioned in the note above, you need to use assumeAlso, after using assume() the first time.
syms Phi_geod(t) lambda_geod(t)
syms Phi_dot_geod(t) lambda_dot_geod(t)
assumptions(Phi_geod)
ans = Empty sym: 1-by-0
assume(Phi_geod(t),"real");
assumptions(Phi_geod)
ans = 
assumeAlso(lambda_geod(t),"real");
assumptions(Phi_geod)
ans = 
assumeAlso(Phi_dot_geod(t),"real");
assumeAlso(lambda_dot_geod(t),"real");
ans = 
assumptions(Phi_geod)
ans = 
  5 件のコメント
Dyuman Joshi
Dyuman Joshi 2024 年 4 月 5 日
編集済み: Dyuman Joshi 2024 年 4 月 5 日
Yes, the class of y is symfun and the class of y(t) is not symfun.
And yes, the statement should be more precise as you have stated.
syms y(t)
class(y)
ans = 'symfun'
class(y(t))
ans = 'sym'
try
assume(y(t),'real')
catch ME
ME.message
end
assumptions
ans = 
try
assume(y,'real')
catch ME
ME.message
end
ans = 'Assumptions on symbolic functions not supported. Make assumptions on symbolic variables and expressions instead.'
y(t) = t^2;
%returns the function definition
y
y(t) = 
%returns the expression
y(t)
ans = 
Christian Luciano Maendle
Christian Luciano Maendle 2024 年 4 月 5 日
Thank you very much! This constructive discussion has made it very clear to me. Thank you for your help! :)

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by