フィルターのクリア

How to solve nonlinear equation?

5 ビュー (過去 30 日間)
Semiha
Semiha 2024 年 5 月 11 日
編集済み: Torsten 2024 年 5 月 11 日
Hello,
I wrote the following code to derive an analytical solution to nonlinear equation but it gives an error. Could you please help me to fix it? Or any suggestion to solve in an analytical way. Thanks
syms x(t);
ode = diff(x,t) == -1*(1-abs(x)^2*x-(1-0.5)*x);
cond = x(0) == 1;
xSol(t) = dsolve(ode,cond);
Warning: Unable to find symbolic solution.
t = 0:1:100;
xSols = xSol(t);
plot(t,xSols)
Error using plot
Invalid data argument.
  1 件のコメント
Torsten
Torsten 2024 年 5 月 11 日
If it helps: You can get t as an analytical function of x, but I think it's not possible to solve for x.

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

回答 (1 件)

Sam Chak
Sam Chak 2024 年 5 月 11 日
編集済み: Sam Chak 2024 年 5 月 11 日
I'm afraid that the nonlinear differential equation may not have an analytical solution. In such cases, you can utilize the 'ode45' solver to obtain a numerical solution.
ode = @(t, x) 1*(1 - abs(x)^2*x - (1 - 0.5)*x);
tspan = [0 10]; % simulation time
x0 = 1; % initial value
options = odeset('RelTol', 1e-4, 'AbsTol', 1e-6);
[t, x] = ode45(ode, tspan, x0, options);
plot(t, x), grid on, xlabel('t'), ylabel('x(t)')
  6 件のコメント
Semiha
Semiha 2024 年 5 月 11 日
I mean diff(x,t) == i(1 - x^3 - 0.5*x) and x(0)=0
Torsten
Torsten 2024 年 5 月 11 日
編集済み: Torsten 2024 年 5 月 11 日
I don't know why for the symbolic solution, not for all t-values solutions for x are returned.
ode = @(t, x) 1i*(1 - x^3 - 0.5*x);
tspan = [0 10]; % simulation time
x0 = 0; % initial value
[t, x] = ode45(ode, tspan, x0);
figure(1)
plot(t, real(x)), grid on, xlabel('t'), ylabel('real(x(t))')
figure(2)
plot(t, imag(x)), grid on, xlabel('t'), ylabel('imag(x(t))')
syms x(t) u
ode = diff(x,t) == 1i*(1 - x^3 - 0.5*x);
cond = x(0) == 0;
xSol = dsolve(ode, cond, 'Implicit', true);
xSol = subs(xSol,x,u);
vpasolve(subs(xSol,t,1),u)
ans = 

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

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by