In a 'for loop' not getting difference of two consecutive iteration
Afficher commentaires plus anciens
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); % main problem is here
end
n=[2:1:100];
plot(n,E(n))
2 commentaires
Geoff Hayes
le 18 Nov 2020
feeroz - where in the above code are you trying to get the difference between two consecutive iterations? How should this difference be calculated?
feeroz babu
le 18 Nov 2020
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur MATLAB dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!