Please help me solve this second order ODE

2 ビュー (過去 30 日間)
Soumya Sinha
Soumya Sinha 2019 年 9 月 10 日
回答済み: Star Strider 2019 年 9 月 10 日
dx1 = x1 + 2*x2;
dx2 = sat(x1) + x2;

回答 (1 件)

Star Strider
Star Strider 2019 年 9 月 10 日
Now that you have explained what ‘sat’ is, you posted two different Questions (this one and Help me solve this second order ODE dx1=x1+2*x2 dx2=sat(x1)+x2) with two similar but different differential equation systems.
These both run without error. Choose the one that best fits your needs:
function bc1()
tspan=[0 10];
IC=[1 1];
[T,X] = ode45(@(t,x) eq1(t,x),tspan,IC);
figure
plot(T,X(:,2))
hold
plot(T,X(:,1))
hold off
title('bc_1')
end
function dx=eq1(t,x)
dx=zeros(2,1);
k=x(2);
sat=@(k) min(max(k,-1),1)
x(2)=k;
dx(1)=sat(x(1)).*x(1)-x(2)
dx(2)=-x(1)-2*x(2)+1
end
and:
function bc2()
tspan=[0 10];
IC=[1 1];
[T,X] = ode45(@(t,x) eq2(t,x),tspan,IC);
figure
plot(T,X(:,2))
hold
plot(T,X(:,1))
hold off
title('bc_2')
end
function dx=eq2(t,x)
dx=zeros(2,1);
k=x(2);
sat=@(k) min(max(k,-1),1)
x(2)=k;
dx(1)=sat(x(1)).*x(1)+x(2)
dx(2)=x(1)+2*x(2)+1
end
Have fun!

カテゴリ

Help Center および File ExchangeParallel Computing Toolbox についてさらに検索

タグ

製品


リリース

R2014a

Translated by