The port "-47" is a bug. I would recommend recommend trying in R2013b (I think it is fixed in this latest release). Also, you can contact technical support to get more information on this bug.
A few things you can try to debug your NaN error:
- Log the states in structure format, that way you will have a block name associated with the values.
- As recommend by Kaustubha, use the debugger. You have the possibility to put a breakpoint ofn Nan, which should help identifiy where this all starts.
- You might want to try this central submission to see what happens between two steps of the simulink solver:
Best Answer