bipolar baseband modulation design

조회 수: 17(최근 30일)
NASA
NASA 2022년 2월 17일
답변: Katie 2022년 4월 2일
Design a bipolar baseband modulation for three pulse shapes:
(i) full-width rectangular NRZ pulse;
(ii) half-width rectangular RZ pulse;
(iii) raised cosine pulse with roll-off factor of 0.4.
(a) Sketch three baseband signal waveforms for 40 bits.
below is the first part of the code, but i keep getting " Array indices must be positive integers or logical values."
%%
N = 1000; % Number of periods
Nb = 20; % Number of samples per period
Nperiods = 20; % Number of periods to display
bipolar = randi([-1 1],N,1);
polari = randi([0 1],N,1);
bipolari = bipolar(polari);
n=0:19;
stem(n,polari(1:20),'fill','r'); ylim([-1.1 1.4]);
hold on
stem(n+0.3,bipolari(1:20),'fill','b');grid
xlabel('n'); ylabel('x(n)'); title('Binary and Bipolar Input')
legend('Binary','Bipolar')
set(gca,'FontSize',14,'XLim',[0 Nb+1],'XTick',[0:1:Nb+1]);
hold off

답변(1개)

Katie
Katie 2022년 4월 2일
polari is an array of 1's and 0's. If for example polari was [1, 1, 0, 1] then bipolari=bipolar(polari) would say that you want bipolari to equal [bipolar(1), bipolar(1), bipolar(0), bipolar(1)] and since Matlab indexing starts at 1, the bipolar(0) entry is causing the "Array indices must be positive integers or logical values." error.
If your goal is for bipolari to only equal bipolar at the indexes where polari is 1, then you could do the following:
bipolari=bipolar(logical(polari));

Community Treasure Hunt

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

Start Hunting!

Translated by