Problem with scripting discrete estimator

If you connect your C-Script with a Display block, you will find that the second output is indeed NaN. NaN and Inf values typically arise due to divisions by 0: 0/0 yields NaN, any non-zero number divided by 0 yields +/-Inf.

The culprit in your C code is this line:

current_value_delta = atan(current_value_psi_mq/current_value_psi_md);

You need to check whether “current_value_psi_md” is zero and in this case calculate “current_value_delta” in a different way.