필터 지우기
필터 지우기

How we can change a Duty Cycle for a signal

조회 수: 2 (최근 30일)
Vijender
Vijender 2013년 9월 15일
Suppose A = 110101011; and i want to form rectangular wave with different duty cycle of each pattern and this pattern is repeating 1000 times. how can i plot this pattern

채택된 답변

Image Analyst
Image Analyst 2013년 9월 15일
Do you have the Image Processing Toolbox, if so, just simply use imresize() to get the new pattern in the length that you want. Try this code:
A = [1,1,0,1,0,1,0,1,1];
newA = A; % Let's say the first cycle is the starting pattern.
for cycle = 1 : 3
% Get a random length for this pattern between 9 and 30
newSize = length(A) + randi(21, 1)
newPattern = imresize(A, [1,newSize], 'Nearest')
newA = [newA, newPattern]
end
  댓글 수: 2
Vijender
Vijender 2013년 9월 15일
편집: Image Analyst 2013년 9월 15일
Thanks for your answer but actually i want to generate a prbs9 sequence and i want to repeat the same pattern(i.e. 511 bits)periodically with different duty cycles. for example the first bit pattern length(i.e 511 bit)have same duty cycle then next bit pattern have different duty cycle and finally i want to generate a eyediagram. my code for prbs9 is given below but i not getting how to repeat the same bit pattern with different duty cycles-
function[c seq]=LFSR(s,t)
%s=initial state of LFSR
s=[1 1 0 0 1 0 1 0 1] %for 9 bit LFSR
%t=tap positions,
t=[5 9]
n=length(s);
c(1,:)=s;
m=length(t);
for k=1:2^n-2;
b(1)=xor(s(t(1)), s(t(2)));
%if m>2;
% for i=1:m-2;
% b(i+1)=xor(s(t(i+2)), b(i));
% end
%end
j=1:n-1;
s(n+1-j)=s(n-j);
s(1)=b(m-1);
c(k+1,:)=s;
end
seq=c(:,n)';
Image Analyst
Image Analyst 2013년 9월 17일
What do you mean by different duty cycles? I took your pattern and basically stretched it out by a random factor. The duty cycle in A is the same, it's just longer or shorter in each random-length stretch of data that I added on. Is that not what you meant? To have a different duty cycle, you'd have to change what's in A, not just make A longer with the same pattern. If you want us to run your code, give typical values for inputs s and t.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Special Functions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by