MATLAB: Why the values for variables in workspace are not the same as presented in command window

displayMATLAB

I am confused about why my variables are different in the workspace and the command window.
here is my screenshot and the L values appears to be 1 in the command window and 86.0104 in the workspace?
and here is my code:
%%solve for V and L
zA = 0.1;
zB = 0.9;
F = 100;
xA= 3.1862e-03;xB= 9.9681e-01;yA= 0.7010;yB= 0.299;
tolr = 1e-5;
z0 = [1 1]';%initial guess for V and L.
err=1e5*rand(2,1);%initial guess for the error
k = 1;
z(:,1) = z0 ;
if sum(err)>=tolr
L = z0(2,k);%1st iteration values
V =(zA*F-xA*L)/yA; z(1,k+1) = V;
L = (zB*F-yB*V)/xB; z(2,k+1) = L;
err = abs(z(:,k+1)-z(:,k));
end
fprintf('V= %d,L= %d\n',z(1,k),z(2,k));

Best Answer

L = z0(2,k);%1st iteration values
You use z0 to find L.
V =(zA*F-xA*L)/yA; z(1,k+1) = V;
You use the value to calculate V.
L = (zB*F-yB*V)/xB; z(2,k+1) = L;
You overwrite L with a new value, and store the new value into z(2,k+1)
k = 1;
k never gets changed, so in particular you stored L into z(2,1+1) -> z(2,2)
fprintf('V= %d,L= %d\n',z(1,k),z(2,k));
You display from z(2,k) which is z(2,1) . The value that is stored in L is what is in z(2,2) not what is in z(2,1)