I believe the problem is here:
dr(2)=(((1+r(1)/c)/d)*(pg-(2*s/r(1))-(4*u*r(2)/r(1))-ps+pv-pa*sin(w*t))+(r(1)/(d*c))*(((3*n*kb*((4*pi*((r(1))^2)/cv)*((l*(T0-r(3))/lth)-pg*r(2))))/A)-(36*pi*(r(1)^2)*r(2)*n*kb*(r(3))/(A^2))-(2*s*r(2)/(r(1)^2))-(4*u*(((r(2))/(r(2)))^2))-w*pa*cos(w*t))-(1.5*((r(2))^2)*(1-(r(2))/(3*c))))/((r(1))*(1-(r(2))/c));
NOTE: r(2)/r(2) in the expression ‘(4*u*(((r(2))/(r(2)))^2))-w*pa*cos(w*t))’
Since ‘r(2)’ is initially zero, this will cause the entire expression to be NaN, which will then propagate throughout your calculations.