How can i optimize the running time in for loops

2 ビュー (過去 30 日間)
Ahmed Hamed
Ahmed Hamed 2015 年 10 月 14 日
編集済み: Ahmed Hamed 2015 年 10 月 14 日
I' trying to compute the Heterogeneous Value Difference Metric distance between objects in numerical data set, I'm using my own code
for i = 1:size(num_data,1)
count = 0;
for j = 1:size(num_data,1)
sim = 0;
for k = 1:size(num_data,2)
sim = sim + ((abs(num_data(i,k) - num_data(j,k)))/...
(max(num_data(:,k))- min(num_data(:,k))))^2;
end
sim = sqrt(sim);
if sim <= threshold
count = count + 1;
numclass(i,count) = j;
end
end
end
where num_data is the numerical data set, but my problem is that the previous code takes too long to run especially when the data set contains a lot of objects. At the same time I'm unable to use parfor because i have dependencies in the loops so, any suggestions to improve the running time.

回答 (0 件)

カテゴリ

Help Center および 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