How to use syms in multiple variable?

1 回表示 (過去 30 日間)
Yokuna
Yokuna 2022 年 4 月 7 日
コメント済み: John D'Errico 2023 年 2 月 27 日
I wrote a code to integrate a function with respect to time, but it gives an error message. I am not able to identify the mistake in writing the code. Please help.
syms x1 x2 x3 t
c1(x1,t)=5*x1^2*t+5*x1+5;
c2(x2,t)=6*x2^2*t+6*x2+6;
c3(x3,t)=7*x3^2*t+7*x3+7;
chi1=diff(c1,x1);
chi2=diff(c2,x2);
chi3=diff(c3,x3);
y1_dot=(-k1*sign(+1*(chi2-chi1))*abs(+1*(chi2-chi1))^mu-k2*sign(+1*(chi2-chi1))*abs(+1*(chi2-chi1))^nu);
y2_dot=(-k1*sign(+1*(chi1-chi2)+1*(chi3-chi2))*abs(+1*(chi1-chi2)+1*(chi3-chi2))^mu-k2*sign(+1*(chi1-chi2)+1*(chi3-chi2))*abs(+1*(chi1-chi2)+1*(chi3-chi2))^nu);
y3_dot=(-k1*sign(+1*(chi2-chi3))*abs(+1*(chi2-chi3))^mu-k2*sign(+1*(chi2-chi3))*abs(+1*(chi2-chi3))^nu);
y1=int(y1_dot,t);
y2=int(y2_dot,t);
y3=int(y3_dot,t);
  3 件のコメント
Walter Roberson
Walter Roberson 2022 年 4 月 7 日
mu and k variables are not defined
John D'Errico
John D'Errico 2023 年 2 月 27 日
Please don't use a flag to say your own question is not clear. If it is not clear, then make it clear.

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

回答 (1 件)

Torsten
Torsten 2022 年 4 月 7 日
This code does not throw an error, but I don't know whether it will succeed to find an antiderivative for your expressions.
syms x1 x2 x3 t k1 k2 mu nu
c1=5*x1^2*t+5*x1+5;
c2=6*x2^2*t+6*x2+6;
c3=7*x3^2*t+7*x3+7;
chi1=diff(c1,x1);
chi2=diff(c2,x2);
chi3=diff(c3,x3);
y1_dot=(-k1*sign(+1*(chi2-chi1))*abs(+1*(chi2-chi1))^mu-k2*sign(+1*(chi2-chi1))*abs(+1*(chi2-chi1))^nu);
y2_dot=(-k1*sign(+1*(chi1-chi2)+1*(chi3-chi2))*abs(+1*(chi1-chi2)+1*(chi3-chi2))^mu-k2*sign(+1*(chi1-chi2)+1*(chi3-chi2))*abs(+1*(chi1-chi2)+1*(chi3-chi2))^nu);
y3_dot=(-k1*sign(+1*(chi2-chi3))*abs(+1*(chi2-chi3))^mu-k2*sign(+1*(chi2-chi3))*abs(+1*(chi2-chi3))^nu);
y1=int(y1_dot,t);
y2=int(y2_dot,t);
y3=int(y3_dot,t);

カテゴリ

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

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by