Solving ODE with boundary conditions

12 views (last 30 days)
Delika Weragoda
Delika Weragoda on 7 Dec 2022
Edited: Torsten on 7 Dec 2022
Is there a way to solve the following ODE with the boundary conditions?
All other parameters A, B, C, D and n are constants.
I tried using bvp4c, but I get an error for incorrect dimensions for raising a matrix power. Did convert all raising power and operation (* and /) using the elementwise operation, but still am unable to get a numerical solution. Would appreciate some guidance. The code I used is given below
Not sure if this is the way to solve this type of ode, if there are alternative ways to get a numerical solution that would be great.
Many thanks
------------------------------------------------------------------------------------------------------------
clc;
clear;
close all;
A = 6.14e-4;
B = -9.4e3;
C = 2.14;
D = 6.72e3
n = 3
yf = 0.3; %Y upper limit
%s0 = 1 - ((C/D)^(1/(n+1))); %calculate the initial values for y = 0
H = ((C/D)^(1/(n+1))) %Function to be subtracted above, for BC at y=0
f = @(y, s) ((A*y + B*s^n)/(n*C + D*(1-s)^(n+1)))*(((1-s)^(n+1))/s^n) %Subjected ds/dy from the above equation
%and simplied
bc = @(ya, yb) [ya(1) - 1 +H; yb(1)];%BC specified for S(0) = 1+H and S(y_f)=0)
ymesh = (0:0.005:yf)
solinit = bvpinit(ymesh, [1 0])
sol = bvp4c(f,bc, solinit)
plot(sol.r, sol.s)

Answers (1)

Torsten
Torsten on 7 Dec 2022
Edited: Torsten on 7 Dec 2022
You have a first-order ODE.
For first-order ODEs, you can prescribe one boundary condition, not two.
Or one of the parameters in the ODE is unknown and to be adjusted for that S satisfies the second boundary condition.

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!