MATLAB Answers

How to solve differential equations while variables are coupled?

1 view (last 30 days)
How to solve U1r, U1i, U2r, and U2i by using MATLAB symlbolic tool ?
Thanks in advance.

  1 Comment

John D'Errico
John D'Errico on 30 May 2020
  1. Please don't post an answer just to thank the person who answered your question.
  2. DO learn to use comments.
  3. And don't accept your own non-answer.
I've unaccepted your non-answer, and accepted Ameer's answer for you.

Sign in to comment.

Accepted Answer

Ameer Hamza
Ameer Hamza on 15 May 2020
Try this code.
syms U1r(t) U1i(t) U2r(t) U2i(t) p n L
eq1 = (p-1)*U1r - diff(U1i) + L*U2r - n*diff(U1r,2) == 0;
eq2 = (p+1)*U1i + diff(U1r) + L*U2i + n*diff(U1i,2) == 0;
eq3 = (p-1)*U2r - diff(U2i) + L*U1r == 0;
eq4 = (p+1)*U2i + diff(U2r) + L*U1i == 0;
eq = [eq1; eq2; eq3; eq4];
cond = [U1r(0)==0 U1i(0)==0 U2r(0)==0 U2i(0)==0];
sol = dsolve(eq, 'IgnoreAnalyticConstraints', true, 'MaxDegree', 4)
However, the analytical solution is a "bit" messy. Following is output of Live script.
I recommend using a numerical method.


Show 3 older comments
Md Bellal Hossain
Md Bellal Hossain on 30 May 2020
How can I get the full solution like you?
When I run then after some result I found ... Output truncated. Text exceeds maximum line length for Command Window display.
Ameer Hamza
Ameer Hamza on 30 May 2020
Run this code in Live script. I guess live script was introduced somewhere near R2017.

Sign in to comment.

More Answers (0)

Translated by