Reducing for loop number

10 visualizaciones (últimos 30 días)
farhad balali
farhad balali el 29 de Oct. de 2019
Editada: Adam el 29 de Oct. de 2019
I would like to reduce the number of for loops since it takes a long time to run this piece of code.
[~ , mm] = size(predictors);
prob = optimproblem('ObjectiveSense','min');
x = optimvar('x',order+1);
prob.Objective = 0;
for j = 1:mm
k = length(residualActual{1, j});
for i = 1:k
w = length(x);
temp =0;
for z = 1:w
temp = temp + x(z) * predictors{1, k}(i,z);
end
prob.Objective = prob.Objective + (residualActual{1, k}(i) - temp).^2 ;
end
end

Respuestas (0)

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by