variables are not updating after each loop in for loop
Afficher commentaires plus anciens
g1 = [1 1 1 1 1 1 1 1 1 1];
g2 = [1 1 1 1 1 1 1 1 1 1];
%disp(g1);
for i = 1:20
y1 = xor(g1(3),g1(10));
y2 = xor(g2(2),g2(3));
y21=xor(g2(6),y2);
y22=xor(g2(8),y21);
y23=xor(g2(9),y22);
y24=xor(g2(10),y23);
y3 = xor(g2(2),g2(6));
output= xor(g1(10),y3);
disp(output);
%put in other xor commands
g1(1) = y1;
g2(1) = y24;
B = circshift(g1,[0 1]);
C = circshift(g2,[0 1]);
end
disp(g1);
disp(g2);

above is the code i hve written as well as the prompt for the project. I belive I have the code written correctly, because I get the correct answer when I run through the code once. When i try to run the for loop 20 times I get the same answer as if there isn't a for loop. I believe the issue has something to do with my for loop. Id greatly appreciate any help, cheers!
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Programming dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!