Power System Blockset | ![]() ![]() |
Example of MATLAB Script Performing a Parametric Study
Let us suppose that you want to perform a parametric study in a circuit named my_circuit
to find the impact of varying an inductance on switching transients. You would like to find the highest overvoltage and for which inductance value it occurred.
The inductance value of one of the blocks contains variable L1
, which should be defined in your workspace. L1
is varied in 10 steps from 10 mH to 100 mH and the values to be tested are saved in a vector L1_vec
. The voltage waveform to be analyzed is stored in a ToWorkspace block in matrix format with V1
variable name.
You may write a MATLAB M-file that will loop on the 10 inductance values and display the worst case:
L1_vec= (10:10:100)*1e-3; % 10 inductances values 10/100 mH V1_max=0; for i=1:10 L1=L1_vec(i); fprintf('Test No %d L1= %g H\n', i, L1); sim('my_circuit'); % performs simulation % memorize worst case if max(abs(V1))>V1_max, imax=i; V1_max=max(abs(V1)); end end fprintf('Maximum overvoltage= %g V occured for L1=%g H\n', V1_max, L1_vec(imax));
![]() | Changing Your Circuit Parameters | Reference | ![]() |