R is a matrix. So the statemen
is meaningless. As well, this if statement
if R <= 0.0001;
is also useless.
The problem is, there is no indication of what you are trying to do. What problem you are trying to solve. (I recall you have asked essentially the same question before.) So it is difficult to know if your implementation is correct.
If your goal is to iterate until the MATRIX R is essentially zero, then a good idea is to test the matrix norm, applied to R.
Next, you can put that test into the while statement. So there is absolutely no need to have an if statement ainside the loop, since the loop will iterate until that test in the while loop is not satisfied.
What else? It is often a bad idea to use i as a loop counter, since i is defined in MATLAB as sqrt(-1).
What else? This is illegal syntax:
dF = 2*ones*(4,1);
What else? R was never defined initially in your code, you you use it in the call to the while loop before it is defined inside the loopitself. You NEED to initialize R.
Given all of that, I might try this code:
K = [ E*A 1 1 1; 1 E*Ix 1 1; 1 1 E*Iy 1; 1 1 1 E*Ixy ];
However, this code seems never to converge.