Any ideas how vectorise this?
Afficher commentaires plus anciens
Playing around with stock selection algorithm, hit this thousands of times any idea how to vectorise this. Any help appreciated.
function distances = calDistances(stocks, geneVector, dayN)
defaultNoData = 100;
distances(length(stocks)) = 100;
% Calculate Distances
for stockN = 1 : length(stocks)
% Get Stock Vector
stockVector = stocks(stockN).getStockVector(dayN);
% No Stock Data Check
if not(isnan(stockVector))
% Euclidian Distance
distances(stockN) = norm(stockVector - geneVector);
else
% Default no data
distances(stockN) = defaultNoData;
end
end
2 commentaires
Jan
le 10 Nov 2017
What is the purpose of "not(isnan(stockVector))"? Do you want:
if all(not(isnan(stockVector)))
?
Harry Smith
le 10 Nov 2017
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur MATLAB Compiler dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!