ODE solver for second Order ODE with Stiffness and Mass Matrices

AI Thread Summary
The discussion focuses on solving a second-order differential equation in matrix form using MATLAB's ODE45 function. The equation involves mass and stiffness matrices, with a specified force vector F(t) defined as F(t)=[F0*sin(w*t), 0, 0, 0]. Participants highlight the need for initial conditions and suggest organizing the code by separating the function into a different script for better execution. A sample code snippet is provided, demonstrating how to set up the matrices and call the ODE solver. The conversation emphasizes the challenges of coding and the importance of proper function organization in MATLAB.
ihebmtir
Messages
3
Reaction score
0
TL;DR Summary
i have encoutered this Problem where i need to solve an ordinary differential Equation using ODE45 for M*u''+K*u=f(t)
i am new to MATLAB and and as shown below I have a second order differential equation M*u''+K*u=F(t) where M is the mass matrix and K is the stifness matrix and u is the displacement.
and i have to write a code for MATLAB using ODE45 to get a solution for u. there was not so much information on how to solve an ODE that´'s written on Matrix form, i would be really thankful for you help
 

Attachments

  • frage.png
    frage.png
    4.5 KB · Views: 180
Engineering news on Phys.org
Do you have a definition for the vector {f(t)}?
 
yes F(t)=[F0*sin(w*t), 0, 0, 0]
and Both M and K are 4X4 Matrices
 
Obviously you will need some initial conditions as well. I will attach a similar example problem and solution code.

It can be a little tricky getting the code to run. You should save the lower function in a separate script (called "f" in this case - since that's what the ode45 function calls) in the working folder. The upper part is what you will run and it calls the other function. There's probably a more elegant way of doing it, but I don't know it.
1624567411995.png

1624567424651.png

xo=[0; 0.1; 1; 0];
ts=[0 20];
[t,x]=ode45('f',ts,xo);
plot(t,x(:,1),t,x(:,2),'--')
%------------------------------------------
function v=f(t,x)
M=[2 0; 0 1];
C=[3 -0.5; -0.5 0.5];
K=[3 -1; -1 1];
B=[1; 1];
w=2;
A1=[zeros(2) eye(2); -inv(M)*K -inv(M)*C];
f=inv(M)*B;
v=A1*x+[0;0; f]*sin(w*t);
 
Thread 'What type of toilet do I have?'
I was enrolled in an online plumbing course at Stratford University. My plumbing textbook lists four types of residential toilets: 1# upflush toilets 2# pressure assisted toilets 3# gravity-fed, rim jet toilets and 4# gravity-fed, siphon-jet toilets. I know my toilet is not an upflush toilet because my toilet is not below the sewage line, and my toilet does not have a grinder and a pump next to it to propel waste upwards. I am about 99% sure that my toilet is not a pressure assisted...
After over 25 years of engineering, designing and analyzing bolted joints, I just learned this little fact. According to ASME B1.2, Gages and Gaging for Unified Inch Screw Threads: "The no-go gage should not pass over more than three complete turns when inserted into the internal thread of the product. " 3 turns seems like way to much. I have some really critical nuts that are of standard geometry (5/8"-11 UNC 3B) and have about 4.5 threads when you account for the chamfers on either...
Thread 'Physics of Stretch: What pressure does a band apply on a cylinder?'
Scenario 1 (figure 1) A continuous loop of elastic material is stretched around two metal bars. The top bar is attached to a load cell that reads force. The lower bar can be moved downwards to stretch the elastic material. The lower bar is moved downwards until the two bars are 1190mm apart, stretching the elastic material. The bars are 5mm thick, so the total internal loop length is 1200mm (1190mm + 5mm + 5mm). At this level of stretch, the load cell reads 45N tensile force. Key numbers...
Back
Top