필터 지우기
필터 지우기

Storing Output in a Matrix from Multiple Iterations

조회 수: 1 (최근 30일)
A M
A M 2017년 1월 26일
답변: Walter Roberson 2017년 1월 26일
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?

답변 (1개)

Walter Roberson
Walter Roberson 2017년 1월 26일
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.

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by