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 Center および File ExchangeOrdinary Differential Equations についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by