Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Matlab中的NaN响应_Matlab_Ode45 - Fatal编程技术网

Matlab中的NaN响应

Matlab中的NaN响应,matlab,ode45,Matlab,Ode45,我使用ode45来求解位置变量与时间的关系,但是在初始条件之后,我只得到所有4个变量的NaN响应。 这是我的功能代码: 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

我使用ode45来求解位置变量与时间的关系,但是在初始条件之后,我只得到所有4个变量的NaN响应。 这是我的功能代码:

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))]
tspan = 0:.01:20; x0 = [60; 0; 5; 0];

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

我怀疑建立这首颂歌的物理原理有问题

在该表达式中,dxdt的第四个元素被一个除法设置为零

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))
此除零导致一个
NaN
,并在迭代求解ODE时传播到其他元素