hi. i got a problem to convert this equation into Matlab code perhaps can help me. it is about summation. thanks
Mostrar comentarios más antiguos

this equation about summation
Respuestas (1)
James Tursa
el 9 de Abr. de 2015
Assuming the variables are each vectors of size N:
sum((theta_bo - theta_mbo).^2) + sum((theta_to - theta_mto).^2)
3 comentarios
mohamad rusydi
el 9 de Abr. de 2015
James Tursa
el 9 de Abr. de 2015
Editada: James Tursa
el 9 de Abr. de 2015
The "sum" function does this looping internally ... you don't have to manually code up a loop. E.g., the following two methods accomplish the same thing:
v = a vector of size 1 x N
% Method 1: Explicit loop
s = 0;
for k=1:N
s = s + v(k);
end
% Method 2: Using the sum function
s = sum(v);
Mohammad Abouali
el 9 de Abr. de 2015
unless if N differs from numel(theta_bo), for some reasons. if you are summing all elements in theta_bo then you don't need to worry about the range of K. But if for some reason you are suming a portion of those vectors then just pass (1:N) to all of them. Most possibly though what James wrote here would work for you though.
Categorías
Más información sobre Mathematics en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!