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

40 vues (au cours des 30 derniers jours)
Richard Hopple
Richard Hopple le 16 Mai 2016
Commenté : Simon Greenwold le 17 Fév 2017
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.
  2 commentaires
Gautam
Gautam le 23 Mai 2016
Hi Richard,
There's a 'Fit to View' option in the Explorer Bar(the bar that appears on the left hand side of the Simulink model). It essentially performs the same function as 'alt+1' and 'Spacebar' shortcuts.
Richard Hopple
Richard Hopple le 6 Juin 2016
Gautam
Yea, I saw that but that doesn't actually help me. I need to program this into a starting script for when open a model

Connectez-vous pour commenter.

Réponse acceptée

James
James le 6 Sep 2016
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.
  1 commentaire
Simon Greenwold
Simon Greenwold le 17 Fév 2017
You can either fit the entire system with
set_param(gcs, 'ZoomFactor','FitSystem')
or just what's currently selected with
set_param(gcs, 'ZoomFactor','FitSelection')

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Modeling dans Help Center et File Exchange

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by