Matlab: two different variables take the same value -


i want implement recursion without recursive function. code following:

for ff=1:6     step=i:-1:1               if (step == maxstep)             r=-1;            if(istm =='1')            r =1;             end        else                dielectricconst =cell2mat(valuearray(step,1));         magnetic =cell2mat(valuearray(step,2));         currentfreq = cell2mat(frequencies(ff));         w = 2*3.1416*currentfreq;          kiz =w*(dielectricconst*magnetic - e0*m0*sin(angle).*sin(angle))^(1/2);          diconstplusone = cell2mat(valuearray(step+1,1));         magplusone =cell2mat( valuearray(step+1,2));         kizplusone =w*(diconstplusone*magplusone - e0*m0*sin(angle).*sin(angle))^(1/2);          res =((diconstplusone*kiz)-(dielectricconst*kizplusone))/((diconstplusone*kiz)+(dielectricconst*kizplusone));          result =(res + r * exp(-((-1)^(1/2))*2*kizplusone*cell2mat( valuearray(step+1,3))))/(1+res*(r)*exp(-((-1)^(1/2))*2*kizplusone*cell2mat( valuearray(step+1,3))));          r=result;         end %      disp(r);     end  end    

res , result values same. pointer problem ?