MATLAB Answers

How to solve this ode problem

1 view (last 30 days)
Boundary value problem
x=0:0.1:3;
Mm =[0 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200 180 160 140 120 100 80 60 40 20 0];
M=spline(x,Mm)
d^2y/dx^2=M ,dy/dx=Q
y(0)=0,y(3)=0
How can i solve this problem in matlab. ODE Bvp4 or dsolve

  0 Comments

Sign in to comment.

Accepted Answer

John D'Errico
John D'Errico on 6 Aug 2020
Edited: John D'Errico on 6 Aug 2020
Use none of them. This is NOT an ODE problem, except that you seemed to want to write it as such. It is certainly not something that dsolve will do, because there is nothing symbolic about the problem.
All you are looking to do is integrate a spline.
fnint will do that, as long as you have the curve fitting toolbox. You want to integate twice.
Because you want to set up a boundary value at x == 3, we need to recognize what is the integral of a constant, and use that to determine the "initial condition" to use for the inner integral. Remember that the value for the second argument to fnint is just a constant thjat will be added to the entire spline, a constant offset. Think of it as the constant of integration.
>> M=spline(x,Mm);
>> MIItemp = fnint(fnint(M));
>> y_3 = fnval(MIItemp,3)
y_3 =
400.25
>> MII = fnint(fnint(M,-y_3/3),0);
>> fnval(MII,0)
ans =
0
>> fnval(MII,3)
ans =
1.0658e-14
MII is itself a spline.
MII =
struct with fields:
form: 'pp'
breaks: [1×31 double]
coefs: [30×6 double]
pieces: 30
order: 6
dim: 1
You can evaluate it, plot it, whatever. In fact, this is the analytical indefinite double integral of the function M, subject to the "boundary" values you indicated. It is defined as a spline, because the original function M was also defined as a spline.

  0 Comments

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by