Changing boundary conditions for ODE
古いコメントを表示
My code below plots the solution of the equation of Mathieu with the initial condition: y(0) = 1, y'(0) = 1
Now I still want the same solution to this problem, but with new boundary conditions: y(1) = -1, y(10) = 1
I tried solving it with dsolve(eq, y(1) == -1, y(10) == 1) but then I couldn't implement it into my function.
syms t y(t)
syms a q
tm = [0 75]; %time intervall
figure(1)
clf
hold on
y0=[-1;1]; %initial conditions
[t,y1] = ode23(@Mathieu, tm, y0);
plot(t,y1(:,2))%y(t)
xlim([0 75])
function dydt = Mathieu(t,y)
a = 2;
q = 0.5;
dydt = [y(2); -(a-2*q*cos(2*t))*y(1)];
end

5 件のコメント
Ameer Hamza
2020 年 5 月 9 日
Your limits of integrations are [0 75]. However, you specified the conditions at t=1 and t=10. Are you trying to solve a multiple boundary problem?
Borjan Trajanoski
2020 年 5 月 9 日
Ameer Hamza
2020 年 5 月 9 日
Yes, you can apply boundary conditions, but you will need to use bvp4c or bvp5c (if multiple boundaries), instead of ode45. If you just care about boundary conditions at [1 10], then see the code in my answer.
Borjan Trajanoski
2020 年 5 月 9 日
Ameer Hamza
2020 年 5 月 9 日
I am glad to be of help.
採用された回答
その他の回答 (1 件)
Nagaraja Shamsundar
2020 年 5 月 9 日
0 投票
Your goal is to solve a boundary value problem (BVP). Some BVPs can be converted into equivalent initial value problems (IVP), but in general it is more appropriate to use a BVP solver such as Matlab's BVP4C instead of an IVP solver such as ODE23.
In Matlab, type help bvp4c or doc bvp4c.
カテゴリ
ヘルプ センター および File Exchange で Ordinary Differential Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
