Effacer les filtres
Effacer les filtres

A for loop that allows me to increase by 2 terms of a vector

2 vues (au cours des 30 derniers jours)
Marco Camozzi
Marco Camozzi le 3 Juil 2020
Hello everyone!
someone could help me to find a loop for that allows me, for a vector of n terms, to perform the following action "coord1 = XY(Edge(i,1),:);" on the first term and the same action on the term n+2?
at the moment I can only increase by one term with the following code.
Thank you!
XY = [0 0;
5 0;
5 -5];
Edge = [1 2;
2 3];
EdgeL = [ 5;
5];
for i = 1 : size(XY,1)
coord1 = XY(Edge(i,1),:);
coord3 = XY(Edge(i,2),:);
end
  1 commentaire
KALYAN ACHARJYA
KALYAN ACHARJYA le 3 Juil 2020
Here the inputs,
XY = [0 0;
5 0;
5 -5];
Edge = [1 2;
2 3];
Now what would be the desired output/logic?

Connectez-vous pour commenter.

Réponse acceptée

Vashist Hegde
Vashist Hegde le 3 Juil 2020
you can use the for loop this way -
for i = 1 :2: size(XY,1)
coord1 = XY(Edge(i,1),:);
coord3 = XY(Edge(i,2),:);
end
This will run the loop on alternate terms.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Produits


Version

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by