PN Sequence Generator Code (2003)

조회 수: 9 (최근 30일)
Anorld Mkombwe
Anorld Mkombwe 2023년 6월 4일
편집: DGM 2023년 6월 4일
%Please assist covert this to run in R2023a Matlab Version:
pntaps = [0 0 1 0 0 0 0 0 0 1];
pninitial = [0 0 0 0 0 0 0 0 0 1];
pndata = zeros(1,1023);
samp per sym = 1;
pnregister = pninitial;
n = 0;
kk = 0;
while kk == 0
n = n+1;
pndata(1,n) = pnregister(1,1);
feedback = rem((pnregister*pntaps’),2);
pnregister = [feedback,pnregister(1,1:9)];
if pnregister == pninitial; kk = 1; end
end
text = [‘The period is ’,num2str(n,15),‘.’];
disp(text)
pndata=replicate(pndata,samp per sym);
kn = n*samp per sym;
pndata = 2*pndata - 1;
a = fft(pndata);
b = a.*conj(a);
Rm = real(ifft(b))/kn;
x1 = (0:length(Rm)-1)/samp per sym;
x2 = 0:100;
subplot(3,1,1)
plot(x1,Rm,‘.k’); ylabel(‘R[m]’)
subplot(3,1,2)
stem(x2,Rm(1:101),‘.k’); ylabel(‘Partial R[m]’)
subplot(3,1,3)
stem(x2,pndata(1:101),‘.k’); ylabel(‘First 100 outputs’)
axis([0 100 -1.5 1.5]);

답변 (1개)

DGM
DGM 2023년 6월 4일
편집: DGM 2023년 6월 4일
I don't see anything that's version-dependent here. I just see a bunch of problems likely caused by copying and pasting code from a website somewhere.
  • MATLAB does not support curly quotes. Use a regular straight single quote mark.
  • Variable and function names cannot have spaces.
  • AFAIK, there is no MATLAB function called replicate(). Maybe that's supposed to be remat(), or maybe something else.
The first two problems (pretty quotes and stripping underscores) end up happening when code is blindly subjected to automated formatting.
pntaps = [0 0 1 0 0 0 0 0 0 1];
pninitial = [0 0 0 0 0 0 0 0 0 1];
pndata = zeros(1,1023);
samp_per_sym = 1;
pnregister = pninitial;
n = 0;
kk = 0;
while kk == 0
n = n+1;
pndata(1,n) = pnregister(1,1);
feedback = rem((pnregister*pntaps'),2);
pnregister = [feedback,pnregister(1,1:9)];
if pnregister == pninitial; kk = 1; end
end
text = ['The period is ',num2str(n,15),'.'];
disp(text)
pndata=repmat(pndata,samp_per_sym);
kn = n*samp_per_sym;
pndata = 2*pndata - 1;
a = fft(pndata);
b = a.*conj(a);
Rm = real(ifft(b))/kn;
x1 = (0:length(Rm)-1)/samp_per_sym;
x2 = 0:100;
subplot(3,1,1)
plot(x1,Rm,'.k'); ylabel('R[m]')
subplot(3,1,2)
stem(x2,Rm(1:101),'.k'); ylabel('Partial R[m]')
subplot(3,1,3)
stem(x2,pndata(1:101),'.k'); ylabel('First 100 outputs')
axis([0 100 -1.5 1.5]);

카테고리

Help CenterFile Exchange에서 Linear Algebra에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by