Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to generate 100 sample data using the AR(1) model?

Status
Not open for further replies.

meto

Junior Member level 1
Joined
Apr 9, 2006
Messages
18
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,399
how to generate 100 sample data using the AR(1) model?I have generated but I don't know this code is true or not.And also how can i calculate the autocorrelation matrix?

"a=0.5;
n=0.001;
x(1)=100;
for k=2:100
x(k)=a*x(k-1)+n;
end"
 

Re: AR(1) model

100 samples are few, but well here is a code with a white noise in the input and the sistem is a AR of order 1


% generate white noise
Fm=25;
w=randn(4*Fm,1); %100 samples of noise
k=-50:50;
a=0.8;
%generate the output of the filter AR process H(z)=1/(1-az^(-1))

x=filter(1,[1 -a],w);

% we get the correlations

rxb0=xcorr(x(1:51),'biased');
rxteo=1/(1-a^2).*a.^abs(-50:50); theoretical correlation

figure(1);clf;
plot(k,rxteo); title('theoric correlation');grid on;

pause;hold on
%biased correlation
plot(k,rxb0,'r'); title('Biased Correlation');

% shift the fft

Sxb0=fft(ifftshift(rxb0));

f=[0:0.5/100:0.5*(1-1/100)]*Fm;
Sxteo=abs(1./fft([1 -a],100)).^2;
figure(2);clf; %Theoric
plot(f,10*log10(real(Sxteo(1:100))));grid on;title('Theoretical Spectral Dentisty Power');
pause; hold on
%biased
plot(f,10*log10(real(Sxb0(1:100))),'r');title('Spectral Dentisty Power');



or you can use [a e]=aryule[x,1]

Regards
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top