load dryer2
Ts=0.08;
Fs=1/Ts;
datos=iddata(y2,u2,0.08);
datosd=detrend(datos,'constant');
datose=datosd(1:500);
datosv=datosd(501:1000);
N=10;
ir=cra(datose,N);
num=ir';
den=[1 zeros(1,length(num)-1)];
model=tf(num,den,0.08);
modelo=idss(model);
figure
compare(datosv,modelo)
g=cumsum(ir);
figure
plot([0:Ts:(length(ir)-1)*Ts],g)
G=spa(datose,128);
% G=spa(datose);    % no anda
figure
bode(G)
W=G.freq;
w=W/Fs;
H=G.responsedata(:);
% HH=G.responsedata;
% H=HH(:);
[num2,den2]=invfreqz(H,w,10,10);
model2=tf(num2,den2,0.08);
modelo2=idss(model2);
figure
compare(datosv,modelo2)
figure
bode(G,modelo2)








