How to vectorize for loops
Ältere Kommentare anzeigen
I am new with Matlab, and I have the a code with two loops and I need vectorize, Can someone help me?
function f = eval_Funcion_RHE(x)
n = length(x);
f = 0;
for i = 1:n
sumaInt = 0;
for j = 1: i
sumaInt = sumaInt + (x(j)^2);
end
f = f + sumaInt;
end
end
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Nearest Neighbors finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!