function Error: Function definitions are not permitted in this context@@

1 view (last 30 days)
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 Comment
Walter Roberson
Walter Roberson on 24 Feb 2014
Which line is it complaining about?
Are you sure that this was not proceeded by a "function" line ?

Sign in to comment.

Answers (0)

Categories

Find more on Shifting and Sorting Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!