variable sweep in simulink

Illustration
nadav yanay - 2021-09-13T15:33:04+00:00
Question: variable sweep in simulink

How do I sweep the value of a "gain block" in simulink? can I do a few iterations, each one with different value in the gain block? Thanks  

Expert Answer

Profile picture of Kshitij Singh Kshitij Singh answered . 2025-11-20

in simulimnk change the name of the gain parameter to for example G. The value for G can then be specified from the workspace. So you can use a for loop like this one:
 
 
 gain=[1:20];
 for n=1:length(gain)
  G=gain(n);
  run('simulink_model_name')
 end
using parfor instead of for can improve performance if you have a multiple core machine.


Not satisfied with the answer ?? ASK NOW

Get a Free Consultation or a Sample Assignment Review!