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: 177
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);
 
Posted June 2024 - 15 years after starting this class. I have learned a whole lot. To get to the short course on making your stock car, late model, hobby stock E-mod handle, look at the index below. Read all posts on Roll Center, Jacking effect and Why does car drive straight to the wall when I gas it? Also read You really have two race cars. This will cover 90% of problems you have. Simply put, the car pushes going in and is loose coming out. You do not have enuff downforce on the right...
I'm trying to decide what size and type of galvanized steel I need for 2 cantilever extensions. The cantilever is 5 ft. The space between the two cantilever arms is a 17 ft Gap the center 7 ft of the 17 ft Gap we'll need to Bear approximately 17,000 lb spread evenly from the front of the cantilever to the back of the cantilever over 5 ft. I will put support beams across these cantilever arms to support the load evenly
Thread 'What's the most likely cause for this carbon seal crack?'
We have a molded carbon graphite seal that is used in an inline axial piston, variable displacement hydraulic pump. One of our customers reported that, when using the “A” parts in the past, they only needed to replace them due to normal wear. However, after switching to our parts, the replacement cycle seems to be much shorter due to “broken” or “cracked” failures. This issue was identified after hydraulic fluid leakage was observed. According to their records, the same problem has occurred...
Back
Top