Ode45 for solution of 4 d.o.f. problem

  • Thread starter bugatti79
  • Start date
  • Tags
    Ode45
In summary, the conversation discusses a code created to find the response time for a 4 dof (degree of freedom) problem. However, the resulting response is not as expected and the conversation suggests possible solutions such as using code tags and checking for errors in the K matrix.
  • #1
794
1
Hi Folks,

I have made up this code in an attempt to find the response time a 4 dof problem. However, I do not get an oscillatory response as I expect, instead I get a straight line which drops off towards the end. Not sure what is happening..any ideas..?

function f = Simple_Planetary(t,y)
f = zeros(8, 1);
f(1) = y(2);
f(2) = -y(7)+2*y(1);
f(3) = y(4);
f(4) = -y(7)+2*y(3);
f(5) = y(6);
f(6) = -y(7)+2*y(5);
f(7) = y(8);
f(8) = 3*y(7)-y(1)-y(2)-y(3)+10*cos(t);

y0 = [1;1;1;1;1;1;1;1];
[t,y] = ode45('Simple_Planetary', tspan, y0);
subplot (211)
plot (t,y (: , 1));
xlabel ('t');
ylabel ('x1 (t)');
subplot (212)

plot (t,y (: , 3));
xlabel ('t');
ylabel ('x2 (t)');

Regards
 
Physics news on Phys.org
  • #2
Two things that may help are enclosing your source code in code tags. This will eliminate the smiley faces.

The second is it seems this is not the whole program as I can't see what span is defined as.

Lastly, what does d.o.f mean?
 
  • #3
Hi, sorry I forgot a line for the span. That is all the code...
4 dof is a 4 degree of freedom system, ie for independent variables that we are solving for
Code:
tspan = [0: 0.01: 20];
y0 = [1;1;1;1;1;1;1;1];
[t,y] = ode45('Simple_Planetary', tspan, y0);
subplot (211)
plot (t,y (:, 1));
xlabel ('t');
ylabel ('x1 (t)');
subplot (212)

plot (t,y (:, 3));
xlabel ('t');
ylabel ('x2 (t)');

Code:
function f = Simple_Planetary(t,y)
f = zeros(8, 1);
f(1) = y(2);
f(2) = -y(7)+2*y(1);
f(3) = y(4);
f(4) = -y(7)+2*y(3);
f(5) = y(6);
f(6) = -y(7)+2*y(5);
f(7) = y(8);
f(8) = 3*y(7)-y(1)-y(2)-y(3)+10*cos(t);
 
  • #4
Could you write down the system of equations you are solving?
 
  • #5
Hi

Sorry for the delay. It turns out the my K matrix was incorrect from which I derived the system of equations and hence the reason for the large numbers because my matrix was nearly singular etc.
 

What is Ode45?

Ode45 is a numerical integration algorithm used to solve ordinary differential equations (ODEs). It is commonly used in scientific and engineering applications.

What is the 4 d.o.f. problem?

The 4 d.o.f. problem refers to a system with four degrees of freedom, meaning it has four independent variables that describe its motion. This could include the position, velocity, and acceleration of four objects in a system.

How does Ode45 solve the 4 d.o.f. problem?

Ode45 uses a combination of explicit Runge-Kutta methods to approximate the solution to the 4 d.o.f. problem. It is a variable-step solver, meaning it adjusts the size of the time steps to improve accuracy.

What types of problems can Ode45 solve?

Ode45 can be used to solve a wide range of ODEs, including both initial value problems (IVPs) and boundary value problems (BVPs). It is particularly useful for stiff systems, where traditional methods may struggle to converge.

What are the advantages of using Ode45?

Ode45 is a robust and efficient algorithm for solving ODEs. It can handle a variety of problem types and provides accurate solutions even for stiff systems. It is also widely available and easy to implement in various programming languages.

Suggested for: Ode45 for solution of 4 d.o.f. problem

Replies
10
Views
2K
Replies
1
Views
1K
Replies
5
Views
884
Replies
2
Views
1K
Replies
8
Views
1K
Replies
1
Views
985
Replies
5
Views
981
Back
Top