function Error: Function definitions are not permitted in this context@@
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentario
Walter Roberson
el 24 de Feb. de 2014
Which line is it complaining about?
Are you sure that this was not proceeded by a "function" line ?
Respuestas (0)
Ver también
Categorías
Más información sobre Shifting and Sorting Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!