WHAT'S THE WRONG IN MY CODE?

2 vues (au cours des 30 derniers jours)
mary pean
mary pean le 16 Nov 2012
function [MLE] = RiskMetrics(data)
sigma2 = zeros(length(data),1);
sigma2(1) = mean(data.^2);
for i = 2 : length(data)
sigma2(i) = (0.06*data(i-1).^2) + (0.94*sigma2(i-1));
end
f = -0.5*log(2*pi*sigma2)-(data.^2)/(2*sigma2);
MLE = sum(f);
end
And MATLAB WINDOW shows me that message: Error using - Matrix dimensions must agree.
Error in RiskMetrics (line 7) f = -0.5*log(2*pi*sigma2)-(data.^2)/(2*sigma2);
I've also tried the 'minus' but nothing...

Réponse acceptée

Matt J
Matt J le 16 Nov 2012
Looks like you need ./ here
(data.^2)./(2*sigma2)
  1 commentaire
mary pean
mary pean le 16 Nov 2012
yap!!!! thank you so much!!!!!!!!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Time Series Events 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!

Translated by