Use set_param () to change the value of one parameter of multiple blocks without using a for-loop
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Is there any alternative to this code?
v = find_system(model,'BlockType','Constant')
for k = 1:length(v)
set_param(v{k},'Value','0')
end
I'm working with a very large model and this code is very inefficient (more than 1 hour).
I would like to avoid the use of the for-loop, setting all the values at the same time. Is it possible?
0 Kommentare
Antworten (1)
Monika Jaskolka
am 7 Dez. 2017
The only alternative that I am aware of is using arrayfun like so:
arrayfun(@(x) set_param(v, 'Value', '0'), v)
However, arrayfun is slower than a for loop (see https://www.mathworks.com/matlabcentral/answers/42335-array-cellfun-vs-for-loop).
0 Kommentare
Siehe auch
Kategorien
Mehr zu Programmatic Model Editing finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!