Help me to find a bug:)
古いコメントを表示
I have e code for Matlab. Could anybody help me to find a bug in it? Code should change reaction for different parameters with variable Alfa and it does not work. The code is below
I = eye(W);
flag = 0;
for i = W+1:(size(data))
%generate X
for window = 1:W
X(i-W,window) = data(i-(W+1-window));
end
%set theta and P or use previous value
if (flag == 0)
theta = t ;
P = alpha*I;
flag = 1;
else
P = P;
end
%calculate prediction
x_tmp = X(i-W,:)';
y_hat = theta' * x_tmp;
%gather the weights and the Y's
weights(i-W,:) = theta;
estimated(i-W,:) = y_hat;
%calc error
e = data(i) - y_hat;
err(i-W,:) = e;
%calc Kalman gain
K = (P*x_tmp)/(2500 + x_tmp'*P*x_tmp);
%update theta and P
theta = theta + K*e;
P = (I - K*x_tmp')*P;
end
end
4 件のコメント
Stephen23
2015 年 5 月 11 日
Sure the code is there, but sorry we can't just imagine where the error occurs. Please help us by giving the complete error message, which includes useful information such as the line of code where the error happens.
Jacek Freyer
2015 年 5 月 11 日
Walter Roberson
2015 年 5 月 11 日
So there is no error message, it just doesn't output what you think it should, but you are not going to provide us with some sample data or what you think the output should be?
Jacek Freyer
2015 年 5 月 12 日
回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Digital Filter Analysis についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!