I have a script that requires a handful of parameters to run. I'm interested in exploring the results as the parameters change, so I define a few scan
arrays at the top, wrap the whole code in multiple for loops
and set the parameters values to the current scan values.
This is error prone and inelegant. The process for changing the code is: 1) reset scan
variables at the top, 2) comment out eg b = scan2(j2)
and 3) uncomment b=b0
.
What's a better method to allow variables to be set to arrays, and subsequently run the code for all such combinations? Example of my code now:
close all
clear all
%scan1 = linspace(1,4,10);
scan1 = 0;
scan2 = linspace(0,1,10);
scan3 = linspace(-1,0,10);
for j3 = 1:length(scan3)
for j2 = 1:length(scan2)
for j1 = 1:length(scan1)
a = a0;
%b = scan2(j2);
b = b0;
%c = c0;
c = scan3(j3);
d = scan2(j2);
%(CODE BLOCK THAT DEPENDS ON variables a,b,c,d...)
end
end
end