I am not a very experienced programmer, so I was hoping to get some useful feedback from this forum. I am coding in matlab and can code to accomplish what I need to do. It probably is not the most efficient coding, but I thought I would give it a shot to see what I could do.
I am trying to create a backtesting program in Matlab where I am doing a parameter sweep of 8 variables for a function by using a set of 8 nested for-loops.
It works fine. But the nested for-loops is a bottle-neck so it takes a very long time for the program to generate results. And it is only using 1 processor when I use nested for-loops.
I believe that I can use all processors if I vectorize my code and get rid of the for-loops entirely which would increase the run time drastically. However, I've tried to vectorize it myself with no luck. Here is the basic layout of the nested for-loops.
for a = 1:5;
for b = 1:6;
for c = 1:7;
for d = 1:8;
for e = 1:9;
for f = 1:10;
for g = 1:11;
for h = 1:12;
[value
,a,b,c,d,e,f,g,h] = function(input,input1(a),input2(b),input3(c),input4(d),input5(e),input6(f),input7(g),input8(h));
end
end
end
end
end
end
end
end
Any help would be greatly appreciated! Thanks in advance!
I am trying to create a backtesting program in Matlab where I am doing a parameter sweep of 8 variables for a function by using a set of 8 nested for-loops.
It works fine. But the nested for-loops is a bottle-neck so it takes a very long time for the program to generate results. And it is only using 1 processor when I use nested for-loops.
I believe that I can use all processors if I vectorize my code and get rid of the for-loops entirely which would increase the run time drastically. However, I've tried to vectorize it myself with no luck. Here is the basic layout of the nested for-loops.
for a = 1:5;
for b = 1:6;
for c = 1:7;
for d = 1:8;
for e = 1:9;
for f = 1:10;
for g = 1:11;
for h = 1:12;
[value
,a,b,c,d,e,f,g,h] = function(input,input1(a),input2(b),input3(c),input4(d),input5(e),input6(f),input7(g),input8(h));end
end
end
end
end
end
end
end
Any help would be greatly appreciated! Thanks in advance!