how can I save the results of every run in a vector?
1 回表示 (過去 30 日間)
古いコメントを表示
MATLAB
2 件のコメント
Kirby Fears
2015 年 12 月 11 日
Is "every run" a function called in a loop? What is returned from each run?
Please give details and examples.
回答 (1 件)
Star Strider
2015 年 12 月 11 日
編集済み: Star Strider
2015 年 12 月 11 日
Create a counter and use every incremented value of it to specify a particular matrix row (or column) or cell array element:
1:
for k1 = 1:N
x(k1) = ... RESULT OF CALCULATION ...;
end
or:
for k1 = 1:N
x{k1} = ... RESULT OF CALCULATION ...;
end
2:
k1 = 1;
while condition = true
x{k1} = ... RESULT OF CALCULATION ...;
k1 = k1 + 1;
end
See the documentation on matrix indexing for details on how to specify rows or columns.
EDIT — To average the vector after you’ve created it, use the mean funciton:
x_mean = mean(x);
3 件のコメント
Star Strider
2015 年 12 月 11 日
If you want to read 60 images, this is one option:
for k1 = 1:60
I=imread('png0015.bmp'); % Read Each Image File
I1=rgb2gray(I);
BW=edge(I1,'sobel');
D=bwdist(BW);
u=D(480,:);
Z(k1)=sum(u)/720;
end
You obviously want to read different image files. There are ways to do that in a loop, but since I have no idea how you named them, I cannot offer specific code to read each one.
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!