How to use syms in multiple variable?

조회 수: 2 (최근 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 CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by