how to set this parameters and coverage settings for simulink model through script?
You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Show older comments
0 votes
I have about 100 unit models in my folder and I have to set the stop time to 1, model zoom level to 100 and disable display block coverage using colors setting for all models.If I do it manually one by one for all models it will consume a lot of time.Can anyone tell me which commands to use or script to do this automatically..
Accepted Answer
Monika Jaskolka
on 22 Apr 2021
models = {'model1', 'model2', 'model3'};
for i = 1:length(models)
m = load_system(models{i});
set_param(m, 'StopTime', '1');
set_param(m, 'ZoomFactor','FitSystem');
% Update other settings...
save_system(m);
end
8 Comments
Harsh kumar
on 23 Apr 2021
Thanks for your code..Rather than using an arrays for models.I have to fetch this models from a folder.Please tell me how to fetch them using for loop from the folder.
Monika Jaskolka
on 23 Apr 2021
Edited: Monika Jaskolka
on 23 Apr 2021
Replace my first line with:
folder = pwd; % Use the current directory
models = dir(fullfile(folder, '*.mdl'));
This searches the current directory, but you can change folder to whatever path you want.
clc;
clear all;
close all;
folder=pwd;
models=dir(fullfile(folder,'*.slx'));
for i=1:length(models)
m=load_system(models{i});
set_param(m,'Stop_Time','1');
set_param(m,'ZoomFactor','100');
save_system(m);
end
I have written this code.after that when i run this script, it is showing error as:
Cell contents reference from a non-cell array object.
Error in script (line 11) m=load_system(models{i});
Harsh kumar
on 23 Apr 2021
my current dir folder contains 3 .slx files(models) and this script only.. please help me how can i ressolve this .
Add this before the for loop:
models = {models(:).name};
Harsh kumar
on 26 Apr 2021
It is working fine for setting stoptime to 1 but unable to set model zoom level to 100%..By using FitSystem in ZoomFactor it is setting it to other values rather than 100%.And while using '100' as value for ZoonFactor there is no change. plz tell me any suitable command to set model zoom level to 100%.
Monika Jaskolka
on 26 Apr 2021
Edited: Monika Jaskolka
on 26 Apr 2021
According to the documentation, the following should work. If it doesn't please submit a bug report to MathWorks.
set_param(m, 'ZoomFactor','100')

Harsh kumar
on 29 Apr 2021
okay..Thank you for the help..
More Answers (0)
Categories
Find more on Interactive Model Editing in Help Center and File Exchange
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)