How to store all values resulting from loop

Hi, Here disp(k1) gives all the values resulting from the for loop.But it store only the last value.How do I store all the values resulting from the for loop. for k=1:70
E_distym(k) = sqrt(sum((featureQ-A(k)).^2));% creating Euclidean distance database for 70 imagesa end A1=[]; for k1=1:70
if(E_distym(k1)<30)
disp(k1);
A1=k1;
end
I

 採用された回答

TAB
TAB 2013 年 3 月 5 日

1 投票

k1_stored = zeros(70,1);
for k1=1:70
if(E_distym(k1)<30)
disp(k1);
k1_stored(kl) = k1;
A1=k1;
end
end

3 件のコメント

maha lakshmi
maha lakshmi 2013 年 3 月 5 日
Thank you sir for the quick response,I have to store only the resultant values from the array and it should not contains zeros.Because I have images named as those values .To display those images I have to store resultant values(only) in an array and display the corresponding images.
TAB
TAB 2013 年 3 月 5 日
編集済み: TAB 2013 年 3 月 5 日
After for loop
resultant = k1_stored(k1_stored~=0);
maha lakshmi
maha lakshmi 2013 年 3 月 5 日
Thank you sir,it works.can you please tell how to display the corresponding images from the resultant(same name as the values in the resultant).

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

製品

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by