How to creat topology with FOR loop
Afficher commentaires plus anciens
Hello everyone,
I'm trying to create random topology, i.e. to connect only specific nodes.
To elaborate better:
Let's say I have matrix
in 1st column (n) are Nodes --> 1,2,3,4,5
in 2nd column (x) are x values of nodes
in 3rd column (y) are y values of nodes
in 5th (a) and 6th (b) column are nodes to which node from 1st column connects to
let's say this is matrix described above (n x y a b):
1 0 0 2 3
2 3 1 4 5
3 1 3 NaN NaN
4 3 7 NaN NaN
5 7 3 NaN NaN
So first I plot nodes
plot(x,y,'o')
hold on
now I want to connect nodes in foward way given in matrix, i.e. node 1 connects to nodes 2 and 3, node 2 connects to nodes 4 and 5, and nodes 3,4,5 don't connect to any node.
I tried some for loop variations none of them worked, seems I simply don't know how to set up for loop to solve this problem.
Any direction and help is appreciated.
Thanks for your time,
Denis.
Réponse acceptée
Plus de réponses (1)
Walter Roberson
le 15 Juin 2016
0 votes
If you have a new enough MATLAB, use graph()
1 commentaire
Denis Fajkovic
le 15 Juin 2016
Catégories
En savoir plus sur Loops and Conditional Statements 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!