function handles to save data

I want to save the Output for every round my loop takes. The Problem; I need an handle and my m-file has no Objects. The Question: How do i define a handle which i can use to store my data.

3 个评论

Max - why do you need a handle? Is your Output the same dimension on each iteration of the loop? If so, then consider using a matrix to store the data from each iteration. If not, then use a cell array.
ok, help me pls. I store each loop "round" in 1 array row. So how do i get an empty 1x9 Array ?
i will go home, sleep 12hours and work again tomorrow. thanks

请先登录,再进行评论。

 采纳的回答

Max - try the following. Suppose the output from one iteration of your loop is a 1x9 vector, and that there are 25 iterations. That means we need a 25x9 matrix:
maxIters = 25;
allData = zeros(maxIters,9);
for k=1:maxIters
% do some work that results in a 1x9 vector
output = ones(1,9);
% save the output to the kth row of the allData matrix
allData(k,:) = output;
end
And that is it. Once outside of the for loop, allData has the output from each iteration.
Try the above and see what happens!

更多回答(0 个)

类别

帮助中心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!

Translated by