How can I automatically increment the values of the variable name in a From/To Workspace Block in Simulink 6.4 (R2006a)?

WIth a model with several To/From Workspace Blocks, I would like to increase an index in the variable names each time the model is run.

 Accepted Answer

The attached model, increment.mdl, loads three variables from the workspace (a0,b0,c0) and then saves them as (a1,b1,c1). The initial a0,b0,and c0 are saved in initial.mat. The script incrementVars.m will find the variables referenced in the To and From Workspace blocks and increment the variable names.
If you want this code run automatically, you can call this MATLAB file from the Model's StopFcn callback (File -> Model Properties -> Callbacks Tab -> StopFcn).

More Answers (0)

Products

Release

R2006a

Tags

No tags entered yet.

Community Treasure Hunt

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

Start Hunting!