Undo changes my application made

조회 수: 2 (최근 30일)
Andreas Kirmeier
Andreas Kirmeier 2021년 3월 4일
답변: Monisha Nalluru 2021년 3월 9일
Hello together!
I made an application that helps me manage my simulink models. The application can automatically create ports, change their names and so on.
However, I noticed that changes in the model made by the application can not be undone by CTRL+Z. This can be really annoying if I happen to create or delete something by accident.
Is there a way simulink registers the changes that were made by the app and therefore is able to undo them?

답변 (1개)

Monisha Nalluru
Monisha Nalluru 2021년 3월 9일
Hi Andreas,
The general way to implement the undo function in an application is to use two states original state and new state. Undo involves changing the current state to the original state and internally marking that you are now one further back in the chain. Redo involves changing the current state to the remembered state and internally marking that you are now one further along in the chain.
The is not function in matlab inorder to implement this.
But if you not familiar with handling states you create one more set of variables(i.e suppose display set and track set of variables) when ever the is change is application set track set values to display set and then assign display set with user current provided values
As an example
%Suppose inital
displayvalue = 10;
trackvalue= 5;
%user makes change in application to 20
trackvalue = displayvalue;
displayvalue = 20;
%user request UNDO
displayvalue = trackvalue
% this model supports only one UNDO
% inorder to support multiple UNDO action use vector

카테고리

Help CenterFile Exchange에서 Schedule Model Components에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by