Clear Filters
Clear Filters

Automate SFunction generation - Simulink workflow

1 view (last 30 days)
Hi,
I've got a subsystem block that I'm generating an SFunction of, which I'm then using in a model.
How do I automate the generation of the SFunction so that when the subsystem changes the SFunction is regenerated, so I can be sure I have the latest version? Any script I can write to do this will be called when the library file containing the subsystem changes, but I don't know what to put in the script.
As far as I can see, if the SFunction is regenerated it will replace all the code files - so it isn't necessary to make any changes to the model that uses it. Please correct me if I'm wrong in this assumption. (This is assuming I can treat the block as a black box and the inputs/outputs won't be changing).
Many thanks,
  1 Comment
James
James on 15 Sep 2011
I want to write a script that is the equivalent of: Right-clicking on a model block, selecting RealTimeWorkshop, then Generate Code, then clicking Build on the dialogue that pops up.
I've been told anything that can be done in the Simulink GUI can be done via the command line. I just don't know how.

Sign in to comment.

Accepted Answer

Kaustubha Govind
Kaustubha Govind on 15 Sep 2011
Try the following:
set_param('subsystem_model', 'SystemTargetFile', 'rtwsfcn.tlc');
set_param('subsystem_model', 'CreateModel', 'off');
rtwbuild('subsystem_model/subsystem_name');

More Answers (1)

TAB
TAB on 15 Sep 2011
You can trace the change in your library file containing subsystem by its 'ModifiedDate'.
Write a script to find the modified date as
% Load model library & get its handle
h=load_system('subsystem_library_model');
% Get object from handle
ho=get_param(h,'object');
% Get last modified date & time
LastMdfd=ho.ModifiedDate;
Output will be in the formate 'Thu Sep 15 16:19:06 2011'
You can save the ModifiedDate in a text file and compare the current obtaind date with saved date .
  2 Comments
James
James on 15 Sep 2011
Thanks Tabrez, but it's not that I'm trying to do.
I want to write a script that is the equivalent of:
Right-clicking on a model block, selecting RealTimeWorkshop, then Generate Code, then clicking Build on the dialogue that pops up.
I need it done a lot so a script to do this will save a lot of time.
James
James on 15 Sep 2011
Well, I am doing that (the script will fire when versioncontrol software sees a change) but that's not the point of the problem.

Sign in to comment.

Categories

Find more on Simulink Coder in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!