MATLAB: What is the correct formula of (sum of …from…to…) in matlab

correct formula

snrin=(-5:5:55); %initial snr
N=length(ecg); % length of ecg signal
n=(0:N-1);
e=sum (ecg^2) from 0 to N-1; **% I want to write this formula correctly**
f=sum (W^2) from 0 to N-1; *% also this*
A=sqrt(e/(10^(snrin/10))*f); *% also this one*

Best Answer

e = sum( ecg(1+n).^2 );
f = sum( W(1+n).^2 );