format long
l=1/2;
u=1/3;
I=[1,0,0;0,1,0;0,0,1];
A=[4,3,3;2,4,1;3,1,2];
B=det(A)*inv(A);
G_1=[1/3,0,0;0,1/2,0;0,0,1];
G_2=[1/4,0,0;0,1/5,0;0,0,1/6];
T=[1,0,0;0,1,0;0,0,1];
F = [1/2,0,0;0,1/2,0;0,0,1/2];
i=1;
x(1) =1;
y(1) =1;
z(1) =1;
X_i=[x(i);y(i);z(i)];
for i = 1:100
a_i = 1/i^(1/2);
t = 1/5;
Z_i = X_i-t*[(I-inv(I+l*G_1))*X_i + B*((I-inv(I+u*G_2)))*A*X_i];
i = i+1;
X_i = a_i*F*X_i+(1-a_i)*T*Z_i
E(i) = norm(X_i);
L(i) = ((x(i+1) - x(i))^3 + (y(i+1) - y(i))^3 + (z(i+1) - z(i))^3)^(1/3);
end
n=[2:1:100];
plot(n,E(n))
2 Comments
Direct link to this comment
https://se.mathworks.com/matlabcentral/answers/652308-in-a-for-loop-not-getting-difference-of-two-consecutive-iteration#comment_1143448
Direct link to this comment
https://se.mathworks.com/matlabcentral/answers/652308-in-a-for-loop-not-getting-difference-of-two-consecutive-iteration#comment_1143448
Direct link to this comment
https://se.mathworks.com/matlabcentral/answers/652308-in-a-for-loop-not-getting-difference-of-two-consecutive-iteration#comment_1143478
Direct link to this comment
https://se.mathworks.com/matlabcentral/answers/652308-in-a-for-loop-not-getting-difference-of-two-consecutive-iteration#comment_1143478
Sign in to comment.