Is there a programatic way to determine if the model workspace is dirty, which is indicated by an asterisk next to "Model Workspace" in the model explorer?

 채택된 답변

Vieniava
Vieniava 2011년 1월 26일

1 개 추천

Check this code out:
Z=get_param(gcs,'ModelWorkspace');
Z.isDirty

댓글 수: 3

Walter Roberson
Walter Roberson 2011년 1월 26일
Does requesting that parameter make the workspace dirty? ;-)
Paul
Paul 2011년 1월 27일
Excellent! Is this documented anywhere? Are there any other undocumented methods of the ModelWorkspace class? If this isn't documented, should I really count on it?
Vieniava
Vieniava 2011년 1월 27일
Your start point could from here http://www.mathworks.com/help/toolbox/simulink/slref/f23-7515.html

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

MG
MG 2018년 2월 8일
편집: MG 2018년 2월 8일

0 개 추천

To determine if the model is dirty:
This means a model has changes that are unsaved.
x = get_param( gcs, 'ModelWorkspace' )
x.isDirty
or
bdIsDirty( gcs )
or
isDirtyOff = strcmp( get_param( gcs, 'Dirty' ), 'off' )
or
isDirtyOn = strcmp( get_param( gcs, 'Dirty' ), 'on' )
To set the dirty bit:
This will trick Simulink to think there are changes that are unsaved.
examples:
  • if you want to save a changed view when there has been no material changes to the model; or
  • you opened or closed some tabs and want to save that change in state when there has been no other material changes to the model.
x = get_param( gcs, 'ModelWorkspace' )
x.isDirty = 1;
or
set_param( gcs, 'Dirty', 'on' )
To save the model:
save_system( gcs )
To close the model:
close_system( gcs )
To save and close the model:
close_system( gcs, 1 )

카테고리

도움말 센터File Exchange에서 Programmatic Model Editing에 대해 자세히 알아보기

제품

질문:

2011년 1월 26일

편집:

MG
2018년 2월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by