Can you help me fix this?
Mostra commenti meno recenti
Im using the following function
function beta = arima(y, p, q, C, sigma)
if nargin < 4
C = 0;
end
if nargin < 5
sigma = 1;
end
y = y(:);
N = length(y);
e = sigma * randn(N, 1);
Y = y - e;
% By = y(1:end-1) y(1:end-2) ... y(:, end-p)
By = arrayfun(@(j) [zeros(j,1); y(1:end-j)], 1:p, 'UniformOutput' , false); By = [By{:}];
Be = arrayfun(@(j) [zeros(j,1); e(1:end-j)], 1:q, 'UniformOutput' , false); Be = [Be{:}];
if C == 0
cvec = [];
else
cvec = ones(N,1);
end
X = [cvec By Be];
x1 = X(any(X,2),:);
beta = lsqnonneg (x1, Y);
end
*In the following code*
a0 = 0.05; a1 = 0.1; b1 = 0.85;
epsi=zeros(3000,1);
simsig=zeros(3000,1);
for i = 1:3000
if (i==1)
simsig(i) = a0 ;
s=(simsig(i))^0.5;
epsi(i) = normrnd(0,1) * s;
else
simsig(i) = a0+ a1*(epsi(i-1))^2+ b1*simsig(i-1);
s=(simsig(i))^0.5;
epsi(i) = normrnd(0,1) * s;
end
end
yt1=epsi.^2;
beta = arima(yt1, 1, 1, 1, 1);
I expect to get
Constant estimate close to 0.05
ar parameter estimate close to 0.95
and ma parameter estimate close to 0.85
However, I am not getting the results .. Can someone fix this please?
5 Commenti
Walter Roberson
il 25 Feb 2013
Which compiler are you using, on which operating system?
Have you tried debugging it at the MATLAB level before generating C / C++ from it?
dav
il 26 Feb 2013
Walter Roberson
il 26 Feb 2013
Your tags include "matlab coder" and "code generation", which have to do with generating C or C++ code. Your other tag, "matlab compiler" needs a C or C++ compiler temporarily in order to generate the final executable even though it does not generate C or C++ code for the MATLAB code itself.
dav
il 27 Feb 2013
Risposte (1)
Jan
il 27 Feb 2013
Of course we cannot fix your function, because we do not know, what you are wanting to calculate. All we have is the code, which might contain a bug anywhere, and the the expected result. But this is not enough information to locate a bug.
Perhaps this simplified questions reveals the core of the problem of your question:
I have two values a=9 and b=10. I add them: |c = a + b| and get 19. But I want to get 20. Please fix the code.
There is an infinite number of possible modifications and based on the given information, it is not possible to decide for a specific one. Ok?
Categorie
Scopri di più su MATLAB Compiler in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!