Borrar filtros
Borrar filtros

Storing Output in a Matrix from Multiple Iterations

3 visualizaciones (últimos 30 días)
A M
A M el 26 de En. de 2017
Respondida: Walter Roberson el 26 de En. de 2017
I am trying to save a certain output (i.e. path) from multiple loop iterations into a matrix. How would this be done?
[dist,path,pred] = graphshortestpath(DG,7,3)
How to store these 'paths' into a matrix for a certain number of iterations?

Respuestas (1)

Walter Roberson
Walter Roberson el 26 de En. de 2017
paths = cell(number_of_iterations,1);
for K = 1 : number_of_iterations
[dist, paths{K}, pred] = graphshortestpath(DG,7,3);
end
Notice that I used a cell array here rather than a numeric array. Shortest path operations will typically return different lengths of outputs for different graphs.

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by