MATLAB: I’m trying to find the RMSD of the numbers by taking 1-2,2-3,3-4 in a sequence ,how can i loop as such ?

MATLABrmsd

I'm right now doing as such,how to form a loop by taking in the previous nos?
N = [ 55378 55344 55310 55276 55242 55208];
a = N(1,1);
b = N(1,2);
RMSDD1 = sqrt ( sum(( b-a).^2 /sum(a).^2) );
fprintf ('the RMSD value between two nos : %f\n' ,RMSDD1);
RMSDDP = RMSDD1*100;
fprintf ('the RMSD value between two nos in % : %f\n' ,RMSDDP);
a = N(1,2);
b = N(1,3);
RMSDD2 = sqrt ( sum(( b-a).^2 /sum(a).^2) );
fprintf ('the RMSD value between two nos : %f\n' ,RMSDD2);
RMSDDP = RMSDD2*100;
fprintf ('the RMSD value between two nos in % : %f\n' ,RMSDDP);

Best Answer

No idea what RMSD is. In your formula,
RMSD = sqrt(sum(b-a).^2 / sum(a).^2);
none of the sum make any sense, since both a and b are scalar. sum has only one number to sum, so it is equivalent to:
RMSD = sqrt((b-a)^2 / a^2); %what was the point of the sums?
Assuming that it is the correct formula, to apply it to each element of your vector it would be:
N = [55378, 55344, 55310, 55276, 55242, 55208];
RMSD = sqrt((N(2:end) - N(1:end-1)).^ 2 ./ N(1:end-1).^2);