MATLAB: How i implement this equation.

matlab function

hey guys,
i am try to implement to loop of follow equation
where Eci is the energy charge by the ith sensor.
hdghd.png

Best Answer

Why do you want a loop to do this simple equation anyways? Ok here you go...
clearvars;
Ne = 9;
Ni = 100;
Eci = rand(Ni,Ne); % I'm assuming this data exists
Ec = zeros(Ni,1);
for i = 1:Ni
tmp = 0;
for e = 1:Ne
Ec(i) = tmp + Eci(i,e);
end
end
Or you could just call sum() once to vectorize the code. I will leave that up to you.