These problems that only happen from time to time can be the hardest to track down and debug. My first guess is that you have a race condition. This means that you aren't correctly controlling the order of execution in your LabVIEW VI. You could be, for instance, writing the value into the Matlab Script Node before you have updated it with a valid value.
This sounds like the case, because errors like these will work sometimes, and fail other times if the timing is not just right. Double check that you're controlling the order of execution in your program, especially if using local variables.
Jarrod S.
National Instruments