MATLAB: Zoom and center Simulink model program (alt+1 & spacebar)

block modelcommandsimulink

Trying to program the same functionality as you see in the "alt+1" and "spacebar" shortcuts into a callback function that will run when you open a model. The best I have found is the Simulink.scrollToVisible function but that doesn't seem to always zoom to 100% and center the models.

Best Answer

Hi Richard,
You can set the Simulink window's view using the system's 'Zoomfactor' parameter. For example:
set_param(gcs,'Zoomfactor','fit to view')
will zoom and centre the current Simulink system as the spacebar does.