Differential Equations Boundary Conditions
1 view (last 30 days)
Show older comments
Trying to solve a set of governing equations and they are already been written as first order equations with boundary conditions. bvp4c solver is used but when I hit the button error messages pop up it seems like the BCs are not correct.
Can someone give suggestions? By the way, if BCs are changed to an arbitrary one containing zb(7) and zb(8) at the last line as bellow it will work, although the BCs are arbitrary and wrong.
res = [za(1); za(2); zb(3); zb(4); za(5); za(6); zb(7)-2.5463e+03; zb(8)+2.5463e+03;];
It seems like the BC cant have two sets of z(1) and z(2).
Here is the codes. Appreciate any input.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function sol=LS1( )
AA=9.949e-06; BB=2.275e-06; CC=7.592e-05; DD=1.736e-05;
odeFunc = @(x,z) ode(x,z,AA,BB,CC,DD); bcFunc = @(za,zb) bc(za,zb); solinit = bvpinit(linspace(0,60,600),[0 0 0 0 0 0 0 0]); sol = bvp4c(odeFunc,bcFunc,solinit);
figure x = sol.x; plot(x/max(x), sol.y(7,:), x/max(x), sol.y(8,:));
function dzdx = ode(x,z,AA,BB,CC,DD) y =0.5*(square(2*pi*(1./60)*(x-59),1)+1); dzdx = [-AA.*(z(7)-z(8))+BB.*y; CC.*(z(7)-z(8))+DD.*y; z(1); z(2); z(3); z(4); z(5); z(6)];
function res = bc(za,zb) res = [za(1); za(2); zb(3); zb(4); za(5); za(6); zb(1)-2.5e+03; zb(2)+2.5e+03;];
0 Comments
Answers (1)
See Also
Categories
Find more on Introduction to Installation and Licensing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!