Solve Differential Equation with initial conditions and function

Hello Everyone,
I have this differential equation: I have defined the function M(x) in the following way:
function M = Moment(x)
a = 800; %mm
b = 200; %mm
L = 1000; %mm
F = 1000; %N
if x<a
V = F*b/L;
M = V.*x;
elseif x >= a
M = F*a*(1-(x/L));
end
end
to solve the differential equation I've defined the following ode function based on previous ones:
xspan = 0:0.0002:1000;
y0 = [0 0];
[x,results] = ode45(@func3,xspan,y0);
function [dy] = func3(x,y)
E = 70000; %N/mm2
I = 32000; %mm4
y1 = y(1);
y2 = y(2);
dy1 = y2;
dy2 = -Moment(x)/(E*I);
dy = [dy1; dy2];
end
The main problem I'm trying to solve is that I have the boundary condition for the displacement y(0) = 0 and y(1000) = 0. I'm able to assign the first BD (i think), but i don't know how to assign the second one, since the solver refears to the function "Moment".
Thank you in advance!

답변 (1개)

Alan Stevens
Alan Stevens 2023년 3월 14일
Try modifying your if statement in Moment. Something like
if x<a
V =...;
M = ...;
elseif x>=a && x<L
M = ...
else
M = 0;
end

카테고리

제품

릴리스

R2022b

질문:

2023년 3월 14일

답변:

2023년 3월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by