user8474858
user8474858

Reputation: 35

Get and set simulation stop time in SIMULINK?

I need to set simulation stop time into a variable in the same simulation; in a gain block I have a variable t that actually is the simulation time and I want it to be set automatically, even I change every time simulation stop time.

Upvotes: 1

Views: 4768

Answers (1)

Shivid
Shivid

Reputation: 1343

Put these in project InitFcn callback;

stop_time_as_str = get_param(gcs, 'StopTime');
t= str2double(stop_time_as_str);

like this:

Right click on the white spot in project window -> select Model properties -> callbacks -> InitFcn

enter image description here

Upvotes: 2

Related Questions