List of Experiments



Download 1.03 Mb.
Page8/11
Date06.12.2022
Size1.03 Mb.
#60081
1   2   3   4   5   6   7   8   9   10   11
Soft computing Lab Mannual
Chapter 20 CORBA, Distributed systems
Experiment: 9


Objective: Write a M-file for adaptive system identification using adaline network.
Solution: The adaline network for adaptive system identification is developed using MATLAB programming techniques by assuming necessary parameters .
Program
% Adaptive System Identification
clear;
clc;
% Input signal x(t)
f = 0.8 ; % Hz
ts = 0.005 ; % 5 msec -- sampling time
N1 = 800 ; N2 = 400 ; N = N1 + N2 ;
t1 = (0:N1-1)*ts ; % 0 to 4 sec
t2 = (N1:N-1)*ts ; % 4 to 6 sec
t = [t1 t2] ; % 0 to 6 sec
xt = sin(3*t.*sin(2*pi*f*t)) ;
p = 3 ; % Dimensionality of the system
b1 = [ 1 -0.6 0.4] ; % unknown system parameters during t1
b2 = [0.9 -0.5 0.7] ; % unknown system parameters during t2
[d1, stt] = filter(b1, 1, xt(1:N1) ) ;
d2 = filter(b2, 1, xt(N1+1:N), stt) ;
dd = [d1 d2] ; % output signal
% formation of the input matrix X of size p by N
X = convmtx(xt, p) ; X = X(:, 1:N) ;
% Alternatively, we could calculated D as
d = [b1*X(:,1:N1) b2*X(:,N1+1:N)] ;
y = zeros(size(d)) ; % memory allocation for y
eps = zeros(size(d)) ; % memory allocation for eps
eta = 0.2 ; % learning rate/gain
w = 2*(rand(1, p) -0.5) ; % Initialisation of the weight vector
for n = 1:N % learning loop
y(n) = w*X(:,n) ; % predicted output signal
eps(n) = d(n) - y(n) ; % error signal
w = w + eta*eps(n)*X(:,n)' ;
if n == N1-1, w1 = w ;
end
end
figure(1)
subplot(2,1,1)
plot(t, xt), grid, title('Input Signal, x(t)'), xlabel('time sec')
subplot(2,1,2)
plot(t, d, 'b', t, y, '-r'), grid, ...
title('target and predicted signals'), xlabel('time [sec]')
figure(2)
plot(t, eps), grid, title(['prediction error for eta = ', num2str(eta)]), ...
xlabel('time [sec]')
[b1; w1]
[b2; w]
Output
[b1; w1]
ans =
1.0000 -0.6000 0.4000
0.2673 0.9183 –0.3996
[b2; w]
ans =
0.9000 –0.5000 0.7000
0.1357 1.0208 –0.0624


Download 1.03 Mb.

Share with your friends:
1   2   3   4   5   6   7   8   9   10   11




The database is protected by copyright ©ininet.org 2024
send message

    Main page