请教为何求出的x全是 NaN? 大家帮看看程序是否有什么问题?
clear all;
clf;
fs=1000;
n=2048;
tspan=0:1/fs:(n-1)/fs;
x0 = [0; 0; 0; 0; 0; 0; 0; 0];
[t,x] = ode45('solution', tspan, x0);
plot(t,x(:,1));
xlabel('t');
ylabel('x(t)');
title('时域图');
function f = solution(t,x)
rb1=0.1;
rb2=0.2;
T1=10;
T2=10;
e=0.0001;
omega2=10;
kg=1e6;
cg=0.08;
J1=1.25e-3;
J2=2e-2;
m2=1;
k2=3.55e6;
c2=0.15;
f = zeros(8,1);
f(1) = x(2);
f(2) = (T1-(kg*(rb2*x(3)-rb1*x(1)+x(7))+cg*(rb2*x(4)-rb1*x(2)+x(8)))*rb1)/J1;
f(3) = x(4);
f(4) = (-T2-(kg*(rb2*x(3)-rb1*x(1)+x(7))+cg*(rb2*x(4)-rb1*x(2)+x(8)))*rb2)/J2;
f(5) = x(6);
f(6) = -m2*e*(omega2)^2*cos(omega2*t)-c2*x(6)+k2*x(5);
f(7) = x(8);
f(8) = -m2*e*(omega2)^2*sin(omega2*t)-c2*x(8)+k2*x(7); |