Using a function in a 'for' loop?
6 次查看(过去 30 天)
显示 更早的评论
My function must take a specified path through an array from one end to the other given a starting position.
For my function, I would like to get two outputs:
1) a 1D array of the row indices of the path
2) a 1D array of the column indices of the path
Is it possible to use a 'for' loop that calls to another function (this function will select the coordinates of the next position, and the next, etc.)? And how would I go about storing the indices to get my output?
2 个评论
采纳的回答
Walter Roberson
2017-9-10
row(1) = 1; col(1) = 1;
for K = 2 : 10
[row(K), col(K)] = calculate_next_step(row(K-1), col(K-1));
end
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!