Solve Differential Equation with initial conditions and function

1 次查看(过去 30 天)
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