0
votes

I'm using ode45 to solve position variables against time, but after the initial conditions, I only get NaN response for all the 4 variables. Here is my function code:

function dxdt = ode(t,x)

global m b a x_teta k_lin k_tor Ip U Pinf gama 

m = 5;        % Mass
b = 1.5;      % Semi-chord
a = 0;        % Reference point to displacement -1 <= a <= 1
x_teta = 0;   % Static unbalanced parameter -> e - a
k_lin = 10;   % Linear stiffness
k_tor = 10;   % Torsional stiffness
Ip = 5;       % Inertia
U = 10;       % Velocity
Pinf = 1.184; % Air density

gama = 2*pi*Pinf*b*U^2; % Constant numbers from L 

% x(1) = h % x(2) = dh/dt % x(3) = teta % x(4) = dteta/dt

dxdt = [x(2);(-gama*x(3)-k_lin*x(1)-m*b*x_teta*(1/Ip)*(b*(.5+a)*gama*x(3)-k_tor*x(3)))/(m+(m^2*b^2*x_teta^2)/Ip);x(4);(-gama*x(3)-k_lin*x(1)-(b*(.5+a)*gama*x(3)-k_tor*x(3))/(b*x_teta))/(m*b*x_teta-(Ip)/(b*x_teta))]

And the implementation code:

tspan = 0:.01:20; x0 = [60; 0; 5; 0];

[t,x] = ode45(@ode,tspan,x0)
1

1 Answers

1
votes

I suspect there's something wrong about the physics for setting up this ODE.

In this expression for the 4th element of dxdt, there is a division by x_teta, which is set to zero.

dxdt(4) = (-gama*x(3)-k_lin*x(1)-(b*(.5+a)*gama*x(3)-k_tor*x(3))/(b*x_teta))/(m*b*x_teta-(Ip)/(b*x_teta))

This division by zero leads to one NaN, and propagates to the other elements as the ODE is iteratively solved.