Reputation: 31
Anybody knows how to get the residuals created by the following matlab code to a vector A
?
I tried to get the residuals by typing r
at the command prompt but did not get the residuals
Thanks.
Code:
clc;
clear;
a0 = 0.05; a1 = 0.1; b1 = 0.85;
nu = randn(2300,1);
epsi = zeros(2300,1);
h = zeros(2300,1);
for i=2: 2300
h(i) = a0 + a1 * epsi(i-1)^2 + b1 * h(i-1) ;
epsi(i) = nu(i) * sqrt(h(i));
end
ytlast=epsi(2300);
htlast=h(2300);
yt1 = zeros(2300,1);
for i=1: 2300
yt1(i) = epsi(i)*epsi(i);
end
yt=yt1(1301:2300);
order = 15;
m = arx(yt1, order);
r = resid(iddata([yt1(1:order);yt1]), m);
r = r(order+1:end);
Upvotes: 2
Views: 233
Reputation: 26069
First use get
to see what r
has:
get(r)
ans =
Domain: 'Time'
Name: ''
OutputData: [2315x1 double]
y: 'Same as OutputData'
OutputName: {'e@y1'}
OutputUnit: {''}
InputData: [2315x0 double]
u: 'Same as InputData'
InputName: {0x1 cell}
InputUnit: {0x1 cell}
Period: [0x1 double]
InterSample: {0x1 cell}
Ts: 1
Tstart: []
SamplingInstants: [2315x0 double]
TimeUnit: 'seconds'
ExperimentName: 'Exp1'
Notes: {}
UserData: []
Then, I assume you want to look at:
r.OutputData
to obtain the vector you wanted...
Upvotes: 4