ANSWER BY KEV HEATON
Hi max,
you are right, when you compile a Simulink model MatLab does perform some optimisation on the generated code which can in some cases remove the ability to monitor a signal.
An easy way around this is to highlight the signal in Simulink as a 'Test Point'. Right click on the signal in the Simulink window, select 'Properties' and check the 'Test Point' box. A blue 'lollipop' will appear on the signal to show that it is now a test point.
When you compile the model and do tg.ShowSignals = 'On', it should now be present in the list.
Regards,
Kev