Alternative to for/while cycle
Show older comments
Hi, I have a question. I'm working at my master thesis and I'm writing a code quite computationally heavy. I'd like to light it and a possible option should be the replacement of the for and while cycles with another option. Do you have idea about any possible replacement?
This is a portion of the code (consider that the table_percentage matrix is already pre-allocated):
for a = ceil((minimum/single_step)+1):(length(steps)-((number_surrogates-1)*(minimum/single_step)))
for b = ceil((minimum/single_step)+1):(length(steps)-((number_surrogates-1)*(minimum/single_step)))
for c = ceil((minimum/single_step)+1):(length(steps)-((number_surrogates-1)*(minimum/single_step)))
for d = ceil((minimum/single_step)+1):(length(steps)-((number_surrogates-1)*(minimum/single_step)))
if steps(a)+steps(b)+steps(c)+steps(d)==1
table_percentage(index,:) = [steps(a), steps(b), steps(c), steps(d)];
index = index+1;
end
end
end
end
end
Thank you very much for every help.
Luca
Accepted Answer
More Answers (1)
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!