MATLAB: The value of y in the while loop doesn’t vary from the previous

while loop

>> n=2;
>>t=520
>> r=5;
>> p=1000;
>> x=n*r*t/p;
a=1; , b=2;
>> y=n*r*t/(p+a*n^2/x^2))+n*b;
while abs(x-y)<= 0.001
x=y;
y=n*r*t/((p+a*n^2/x^2))+n*b;
end

Best Answer

I suspect you will find that your while loop body is not executing at all.