フィルターのクリア

Can't susbsitute a variable that is defined

2 ビュー (過去 30 日間)
Jacques Barsimantov
Jacques Barsimantov 2023 年 2 月 17 日
I have solved a system of ODEs using dsolve. They create a set of symbolic variables inside the solutions when integrating as expected. When I check to see the name of these integrationg constants one of these is called "C1". Now, I want to substitue using subs that integration variable for a number.
symvar(Vb_sol) %Check the name of the constants inside my ODE solution
V_sub = subs(Vb_sol,C1,1) %Replace C1 (integration constant) by 1
However, when I try do do the substitution I get the "Undefined function or variable 'C1'" error.
I have attached the variable "Vb_sol", which is a function of C1, and an example script trying to do the substituion.
Thank you

採用された回答

Paul
Paul 2023 年 2 月 17 日
編集済み: Paul 2023 年 2 月 17 日
Do
syms C1
before calling subs.
syms y(t) a
eqn = diff(y,t) == a*y;
S = dsolve(eqn)
S = 
syms C1
subs(S,C1,2)
ans = 
  1 件のコメント
Jacques Barsimantov
Jacques Barsimantov 2023 年 2 月 17 日
Thanks, that worked!

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by