function Error: Function definitions are not permitted in this context@@
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
for calcstatsidx = 1:size(stockReturn,2)
stockStats(calcstatsidx).Stock = stockReturn(calcstatsidx).Stock;
annualizedReturn = stockReturn(calcstatsidx).Return .* annualizemultiplier;
stockStats(calcstatsidx).sampleSize= size(annualizedReturn,1)/numOfBucketsInADay;
stockStats(calcstatsidx).mean = nanmean(annualizedReturn);
stockStats(calcstatsidx).median = nanmedian(annualizedReturn);
stockStats(calcstatsidx).standardDeviation = nanstd(annualizedReturn);
stockStats(calcstatsidx).medianAbsoluteDevation = mad(annualizedReturn,1);
stockStats(calcstatsidx).skew = skewness(annualizedReturn,0);
stockStats(calcstatsidx).kurtosis = kurtosis(annualizedReturn,0);
sorted = sort(annualizedReturn);
if size(sorted, 1)>=10
stockStats(calcstatsidx).max10 = sorted(end-9: end);
stockStats(calcstatsidx).min10 = sorted(1:10);
else
stockStats(calcstatsidx).max10 = sorted;
stockStats(calcstatsidx).min10 = sorted;
end
end
The variable "stockStats" change size in every loop iteration. Consider preallocating for speed"!
Thank you for any helps!
1 commentaire
Walter Roberson
le 24 Fév 2014
Which line is it complaining about?
Are you sure that this was not proceeded by a "function" line ?
Réponses (0)
Voir également
Catégories
En savoir plus sur Shifting and Sorting Matrices dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!