Borrar filtros
Borrar filtros

How we can change a Duty Cycle for a signal

3 visualizaciones (últimos 30 días)
Vijender
Vijender el 15 de Sept. de 2013
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

Respuesta aceptada

Image Analyst
Image Analyst el 15 de Sept. de 2013
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 comentarios
Vijender
Vijender el 15 de Sept. de 2013
Editada: Image Analyst el 15 de Sept. de 2013
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 el 17 de Sept. de 2013
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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Dialog Boxes en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by