MATLAB: Calculation of cosh, sinh big numbers

coshsinh

Hi,
let t is time. How can I calculate and plot:
for i=1:10
y=0.912*sin(314.0*t) - 3.31*cos(314.0*t) + (3.31*(cosh(1399.0*t) + 0.484*sinh(1399.0*t)))/exp(1500.0*t)
current(:,i)=(eval(y))'
end
I got NaN from cosh and sinh for time 0.51….how can I block cosh, sinh if actual value is NaN?
Thank you

Best Answer

All three quantities, cosh(1399.0*t), sinh(1399.0*t), and exp(1500.0*t), will fall far beyond the realmax limit. I would suggest you refer to the definitions of sinh and cosh and modify your expression as follows. Replace cosh(1399.0*t)/exp(1500.0*t) by (exp(-101*t)+exp(-2899*t))/2 and similarly with sinh. That way you will not get NaNs even though these are equivalent expressions.