I would like to do some input validation of the block mask parameters, and in the case that the input is out of range, output an error message.
Using "errordlg" is annoying because if the parameter is a workspace variable that changes and you've used the block in N places in the model, suddenly you have N pop-up dialogs.
Using the Command Window to display these errors is a more comfortable option. But when I try the following inside the Initialization tab of the mask editor:
if num<0 error('Number must be positive: "%s"', gcb); end;
I get a pop-up anyway saying: Error due to multiple causes. --> Error in 'untitled/myblock': Initialization commands cannot be evaluated. --> Number must be positive: "untitled/myblock"
Is there any way to get Simulink to output to the Matlab command window?
disp() command would display whatever you want to display in the command window.
After my research I recommend using Block Callbacks (InitFcn) to validate inputs. Using "error" in these callbacks creates an error in the Simulink Diagnostics during update and provides a nice link and highlight to the affected block. I would only recommend this from R2012a and on. R2011b has a small bug, instead of getting 1 error you will get 2 (block and model error), but I can still live with this.