Borrar filtros
Borrar filtros

How to implement the following algorithm in MATLAB ?

3 visualizaciones (últimos 30 días)
charu shree
charu shree el 31 de Mzo. de 2023
Comentada: charu shree el 4 de Abr. de 2023
Hello all, I am trying to implement MATLAB code for following statements of one of the algorithm which is as follows:
  1. We consider that there are multiple cellular towers. These towers are called as nodes, where node i and node j are neighbours of each others.
  2. We consider one of the towers among all the towers as the Macro tower (MT).
  3. Let the minimum number of hops from tower to the MT be denoted as .
After going through web, I understand that number of hops can be computed using Bellman ford algorithm.
My query is that how to implement the Bellman ford algorithm in this scenario.
Any help in this regard will be highly appreciated.
  1 comentario
charu shree
charu shree el 31 de Mzo. de 2023
Can we use Graph function in MATLAB for implementing the nodes ?

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 1 de Abr. de 2023
sr = [1 1 1 1 2 2 2 2 3 3 4 5 5 5 5 6 6 6 6 6]; % various possible sources
ta = [2 6 7 8 3 7 5 8 4 8 8 4 3 7 8 5 4 7 3 8]; % various possible targets
G = graph(sr,ta);
p = plot(G);
target = 8;
[TR, d] = shortestpathtree(G, 'all', target, 'outputform', 'cell')
TR = 8×1 cell array
{[ 1 8]} {[ 2 8]} {[ 3 8]} {[ 4 8]} {[ 5 8]} {[ 6 8]} {[7 1 8]} {[ 8]}
d = 1×8
1 1 1 1 1 1 2 0
  3 comentarios
Walter Roberson
Walter Roberson el 1 de Abr. de 2023
Each cell in TR shows the exact path from one node to the target. d summarizes the cost of each path.
charu shree
charu shree el 4 de Abr. de 2023
Ok ....Thank u sir....

Iniciar sesión para comentar.

Más respuestas (1)

Steven Lord
Steven Lord el 31 de Mzo. de 2023
See the shortestpath and/or shortestpathtree functions for graph objects.
  2 comentarios
charu shree
charu shree el 1 de Abr. de 2023
Thank you so much sir for ur response.....
Following are my efforts:
sr = [1 1 1 1 2 2 2 2 3 3 4 5 5 5 5 6 6 6 6 6]; % various possible sources
ta = [2 6 7 8 3 7 5 8 4 8 8 4 3 7 8 5 4 7 3 8]; % various possible targets
G = graph(sr,ta);
plot(G);
I had created the Graph of possible sources and targets of mobile towers.
But still not getting how to compute number of hops from tower to MT.
Please note that I am assuming node 8 to be MT i.e., Macro tower.
charu shree
charu shree el 1 de Abr. de 2023
How to generalize the above code if there are large number of mobile towers say 60 ?

Iniciar sesión para comentar.

Categorías

Más información sobre Just for fun en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by