Not able to use ode45 to solve and plot solution to vdp equation

2 ビュー (過去 30 日間)
Louis Sharma
Louis Sharma 2019 年 11 月 28 日
編集済み: Stephan 2019 年 11 月 28 日
Hello, I am trying to solve the vdp equation for the case where mu=1.
I am not able to obtain the solution. The error is that the vector returned by the differential equation and the one returned by the initial conditions do not have the same dimensions.
Any help would be great!
Here is my code:
f=@(t,Y) [(1-x^2)*Y(2); -Y(1)]
cond1= x(0)==2
cond2= Dx(0)==0
conds= [cond1, cond2]
tspan= [0 10]
[t,ylim]= ode45(f,tspan, conds)
x=Y(:,1); Dx=Y(:,2);
figure
plot(t,x)

採用された回答

Stephan
Stephan 2019 年 11 月 28 日
編集済み: Stephan 2019 年 11 月 28 日
You are missing some things. Looks like a mix of numeric and symbolic calculations, which won't work. But tou have luck - exactly this is an example in the documentation, so you can learn how to tackle this correctly:

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by