% program ex_15_3.m to generate data for model selection % programmed by B.Joseph Dec 27, 2000 % % first generate data % % we will use a prbs signal on a known system to generate data % a first order system with g(s)=1/(s+1) is considered % clear close;echo on;clc; sys=tf([1],[1 1]) % convert to discrete time sysd=c2d(sys,.1) % get prbs input signal covering freq from .1 to 10 % prbs is a matalb mfile that generates sequences of % random pulses % see chapter 16 for a description clc; echo on; u=prbs(.5,10,.1,1);u=[u;u]; t=0:.1:length(u)*.1-.1; % this computes the time sequence % obtain response of system % [y,t]=lsim(sysd,u); % add some noise to the data % divide the data into two parts one for testing len=fix(length(y)/2); u1=u(1:len);y1=y(1:len);ut=u(len+1:2*len);yt=y(len+1:2*len); y1=y1+randn(length(y1),1)*0.1; ; save ch15ex3.mat