Corso di Identificazione dei Modelli e Analisi dei Dati (AA 2009-2010) Prof. Sergio Bittanti Esercitazione di laboratorio
Sommario Serie temporali e sistemi Generazione Analisi Predittori di serie temporali e sistemi Identificazione Esercizi
Serie temporali e sistemi Generazione di sistemi a tempo discreto (rappresentazione esterna) >> system = tf(num,den,ts) num: numeratore den: denominatore Ts: tempo di campionamento (-1 default) >> system=tf([1 1],[1-0.8],1) Transfer function: z + 1 ------- z - 0.8
Serie temporali e sistemi Analisi del sistema: Zeri e poli: >> [Z,P,K]=zpkdata(sistema) Z = [-1] % posizione degli zeri P = [0.8000] % posizione dei poli K = 1 % guadagno Diagramma di Bode: >> [A,phi] = bode(sistema,w) W: valori della frequenza w in cui calcolare A(w) e phi(w) A: amplificazione (A(w)) Phi: sfasamento (phi(w))
Serie temporali e sistemi Diagramma di Bode: >> [A,phi] = bode(sistema,[0.1 1]) A(:,:,1) =9.1179 A(:,:,2) =1.9931 phi(:,:,1) =-24.2456 phi(:,:,2) =-78.5036 >> bode(sistema) >> % disegna il diagramma (modulo db- e fase)
Serie temporali e sistemi Risposta del sistema a ingressi Risposta allo scalino >> T=[0:Ts:Tfinal]; >> [y,t]=step(sistema,tfinal); % step response >> step(sistema,tfinal) % plot Risposta a un ingresso qualsiasi >> T=[0:Ts:Tfinal]; >> u=sin(0.1*t); % ingresso sinusoidale >> [y,t]=lsim(sistema,u,t); Rumore bianco >> N=100; % numero di campioni >> lambda=1; % deviazione standard >> mu=1; % media >> u=mu+lambda*randn(n,1);
Serie temporali e sistemi Analisi di serie temporali >> u=1+randn(3000,1); >> [y,t]=lsim(sistema,u,[1:3000]); Funzione di covarianza ( ) >> gamma=covf(y,10) % tau=0,1,,10-1 >> plot([0:9],gamma) Attenzione: covf calcola la funzione di correlazione! BISOGNA DEPOLARIZZARE IL SEGNALE Spettro (!) metodo del periodogramma >> periodogram(y) >> [Pxx,w]=periodogram(y); >> plot(w/pi,10*log10(pxx))
Serie temporali e sistemi IMAD_LAB simulink toolbox
Predittori Dato il sistema y(t) = B(z) A(z) C(z) u(t ) + A(z) e(t), e(t) = WN(0; 2) il predittore a k passi si calcola come ^y(t=t k) = B(z)E k(z) u(t ) + R k(z) C(z) = B(z)E k(z) C(z) C(z) y(t) u(t ) + ~ R k (z) C(z) dove E k (z) e R k (z) sono quoziente e resto della lunga divisione, e R(z) = R(z)z ~ k (si calcolano a mano ) y(t k)
Predittori e(t) C(z) A(z) S P u(t) z B(z) A(z) y(t) y(t k) k z ~R k (z) C(z) ^y(t=t k) B(z)E k (z) C(z)
Identificazione >> ident % start the MATLAB identification toolbox GUI
Identificazione IMAD_LAB simulink toolbox
Identificazione Altre istruzioni Matlab (2 Identification toolbox) Parametric model estimation ar - AR-models of signals using various approaches. armax - Prediction error estimate of an ARMAX model. arx - LS-estimate of ARX-models. bj - Prediction error estimate of a Box-Jenkins model. init - Initialize (randomize) the parameters of a model. ivar - IV-estimates for the AR-part of a scalar time series. iv4 - Approximately optimal IV-estimates for ARX-models. n4sid - State-space model estimation using a sub-space method. nlarx - Prediction error estimate of a nonlinear ARX model. nlhw - Prediction error estimate of a Hammerstein-Wiener model. oe - Prediction error estimate of an output-error model. pem - Prediction error estimate of a general model.
Identificazione Model structure selection aic - Compute Akaike's information criterion. fpe - Compute final prediction criterion. arxstruc - Loss functions for families of ARX-models. selstruc - Select model structures according to various criteria. idss/setstruc - Set the structure matrices for idss objects. struc - Generate typical structure matrices for ARXSTRUC. Per maggiori dettagli si veda: >> help ident
Esercizi
Esercizi
Esercizi
Esercizi
Esercizi
Esercizi
Esercizi
Esercizi
Esercizi
Esercizi