Solve Differential Equation with initial conditions and function

1 visualizzazione (ultimi 30 giorni)
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!

Risposte (1)

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

Categorie

Scopri di più su Programming in Help Center e File Exchange

Prodotti


Release

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by