% 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], 'InputDelay',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(.2,1,.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 y=y+randn(length(y),1)*0.1; z=[t u y]; save ch16pr1a.dat z -ascii