Solve Differential Equation with initial conditions and function

조회 수: 1 (최근 30일)
SamuLibero
SamuLibero 2023년 3월 14일
답변: Alan Stevens 2023년 3월 14일
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

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by